-
Notifications
You must be signed in to change notification settings - Fork 367
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
Add replace!(::AbstractDataFrame, cols, ...) method #2257
Comments
Why:
is not enough for you? (this would be in-place) The issue with So let us wait what others think. |
Hmm, well I think my suggested API for the julia> df = DataFrame(a = 2:3);
julia> transform(df, :a => (x -> log.(x)) => :log_a)
2×2 DataFrame
│ Row │ a │ log_a │
│ │ Int64 │ Float64 │
├─────┼───────┼──────────┤
│ 1 │ 2 │ 0.693147 │
│ 2 │ 3 │ 1.09861 │
julia> transform(df, :a => ByRow(log) => :log_a)
2×2 DataFrame
│ Row │ a │ log_a │
│ │ Int64 │ Float64 │
├─────┼───────┼──────────┤
│ 1 │ 2 │ 0.693147 │
│ 2 │ 3 │ 1.09861 │ That feels to me like But it could be my bias coming from R/dplyr where table manipulation is usually column based. |
A nice side benefit would be that function foo(df)
replace!(df.x, 9 => missing) # only returns the array :x
df
end which would reduce to this under the new syntax: function foo(df)
replace!(df, :x, 9 => missing)
end |
This is true that |
I think that But I'm in favor of The It'd remove a small pain point for new users, I think |
another option is just:
|
The manual shows how to replace values in multiple columns, e.g.
That's a neat trick, but it would be convenient if we had
replace
andreplace!
methods for data frames. Something like the following:Of course the
eltype
conversion behavior would mirror the behavior forBase.replace
:The text was updated successfully, but these errors were encountered: