-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow :col => AsTable and :col => cols #2780
Conversation
@@ -287,6 +293,11 @@ function normalize_selection(idx::AbstractIndex, | |||
@nospecialize(sel::Pair{<:ColumnIndex, <:Base.Callable}), renamecols::Bool) | |||
c = idx[first(sel)] | |||
fun = last(sel) | |||
|
|||
if fun === AsTable | |||
return normalize_selection(idx, first(sel) => identity => AsTable, renamecols) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. No reason to worry about copies because it's only a vector of named tuples, so we always allocate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - AsTable
as destination will always allocate:
julia> df = DataFrame(a=1)
1×1 DataFrame
Row │ a
│ Int64
─────┼───────
1 │ 1
julia> df2 = select(df, :a => identity => AsTable, copycols=false)
1×1 DataFrame
Row │ x1
│ Int64
─────┼───────
1 │ 1
julia> df2.x1 === df.a
false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but given that it introduces a new error I wouldn't backport this to a patch release.
I want it to be added in 1.2 release. |
Thank you! |
Can we get a release and a tag for this? DataFramesMeta has some weird results without it. |
I would like to make a release, but here is the list of things that need to happen before: #2797 (comment) Sorry for the delay. |
Sounds good. Sorry for not looking at the sub-dataframe issue. I promise to look at it soon. |
No rush with this. But could you review the blocking issues please? Thank you! |
Fixes #2779
This is mildly breaking but I would classify the current behavior as a bug (oversight).