JuliaData / JuliaData/DataAPI.jl
Column selectors should guarantee column order is preserved
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 35
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
I think that all column selectors (other than arrays) should guarantee that the column order in the original table is preserved. One would certainly expect that to be the case for Between, though it's not explicitly mentioned in the docstring. It would be a bummer if you had foo(x, y) = 2x .+ y but Between(:x, :y) => foo happened to lower to [:y, :x] => foo instead of [:x, :y] => foo.
And I think it makes sense to guarantee column order preservation for the other selectors. E.g.
df = DataFrame(a=1, b=2, c=3)
select(df, Not(:b) => foo)
should be guaranteed to lower to
select(df, [:a, :c] => foo)
rather than
select(df, [:c, :a] => foo)
I'm not totally certain the best way to specify the column ordering properties of Cols, but I think this specification makes sense:
- Individual column selectors inside
Colsare first lowered to (ordered) arrays.- The lowering of the individual column selectors (except for arrays) follows the rule above that table column order should be preserved.
Colsis then lowered as follows:Cols(A, B, C) ==> [A, B\A, C\(A ∪ B)](where the arguments on the right side are splatted into the array).
Since setdiff on arrays preserves the order of the first argument to setdiff, we get the following behavior:
df = DataFrame(a=1, b=2, c=3)
Cols([:c, :b], [:a, :b]) == [:c, :b, :a]
Cols(r"[bc]", r"[ab]") == [:b, :c, :a]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the column-selector and Cols behavior described in the issue, using the provided select and Cols examples as cases. Define and test order preservation for individual selectors and for overlapping Cols arguments; done means the resulting selector orders match the specified examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100