Conversation
nalimilan
left a comment
There was a problem hiding this comment.
Makes sense. Have you thought about other functions that we could want to implement (or not) for DataFrameRow? For example, we could allow deletecols!, but it could also be a bit more dangerous...
| "columns of its parent data frame is disallowed")) | ||
| end | ||
| T = typeof(val) | ||
| newcol = similar(val, Union{T,Missing}, nrow(parent(dfr))) |
There was a problem hiding this comment.
Use Tables.allocate_column? similar is for arrays.
Or maybe just call insertcols! to avoid duplication? Is that slower?
There was a problem hiding this comment.
This is a very good point. I used similar, because we already had it in
https://github.com/JuliaData/DataFrames.jl/blob/main/src/subdataframe/subdataframe.jl#L207
which also requires fixing then.
Other places with the same issue are e.g.:
DataFrames.jl/src/other/broadcasting.jl
Line 204 in 8c32d53
DataFrames.jl/src/dataframe/insertion.jl
Line 313 in 8c32d53
Do you think we should do a systematic review of them and fix this everywhere?
There was a problem hiding this comment.
I thought we followed the policy that similar is called when we have a vector to pass to it, and otherwise allocatecolumn is used. Apparently that's not really the case, given the example in broadcasting.jl. The two other examples look correct to me. We could try changing the broadcasting.jl one and check whether other places have the same issue.
Now I just added functions that match what we support for |
Co-authored-by: Milan Bouchet-Valat <nalimilan@club.fr>
…rames.jl into bk/row_insertion
Right, I just wanted to think about the broader implications of this PR. Mirroring what we do for |
Fixes #3390
@nalimilan - I just did the initial implementation. Let us first decide if we like the functionality and if yes, I will document and test it.