-
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
Document custom generation of column names in manual #3430
Comments
This is the intended way to do it:
You can then even do just e.g.:
|
Thank you very much - I couldn't find such an example in the documentation. I still don't understand why your second version works 😅. This approach has the disadvantage that one needs to replicate which fields the transformation function has. Looks flexible, and easy to understand, which is really great, but also like duplication. |
Yes - this is a disadvantage. That is why I have commented that you do not have to pass these column names in the function (the example with We could allow for a function taking both "source column names" and "names returned by a function" and allowing combining them, but it seemed overly complex (i.e. the API would be hard for typical users to understand and learn). What I have given you was the most concise variant. The variant that you want is available, and it avoids duplication, but the disadvantage is that the code is longer (so I thought that it is less interesting):
|
Could an example be added to https://dataframes.juliadata.org/stable/man/working_with_dataframes/? |
There is an example in the docstring. https://dataframes.juliadata.org/stable/lib/functions/#DataFrames.combine. We could add also something in the intro manual. Could you propose something that you would find most useful? |
AsTable
is not compatible with .=>
I think just below julia> combine(df, names(df) .=> sum, names(df) .=> prod)
1×4 DataFrame
Row │ A_sum B_sum A_prod B_prod
│ Int64 Float64 Int64 Float64
─────┼─────────────────────────────────
1 │ 10 10.0 24 24.0
# this is new:
julia> combine(df, names(df) .=> Ref ∘ extrema .=> (c -> c .* ["_min", "_max"])) Probably with a little extra explanation what the |
See #3433 for an update of the manual. Of course please comment if something is not clear or should be improved. |
looks especially good. Thank you for the detailed documentation improvement! |
I am looking for a fix or workaround for how to use
AsTable
in combination with several columns which should be transformed, i.e..=>
.I always get
ERROR: ArgumentError: Duplicate column name(s) returned:
throws the following error
My ideal behaviour would be that AsTable prepends the column name, but of course this would be breaking.
Maybe there could be a
PrependColName(AsTable)
wrapper or something similar?The text was updated successfully, but these errors were encountered: