Skip to content
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 rename/rename! of columns #16

Closed
juliohm opened this issue Dec 10, 2020 · 3 comments
Closed

Add rename/rename! of columns #16

juliohm opened this issue Dec 10, 2020 · 3 comments

Comments

@juliohm
Copy link

juliohm commented Dec 10, 2020

Would a function like DataFrames.rename be welcome in Tables.jl? I can try submitting a PR in the affirmative case.

@quinnj
Copy link
Member

quinnj commented Dec 10, 2020

I don't think this makes sense for Tables.jl; the Tables.jl interfaces are very much centered around the producer-consumer workflow; i.e. making generic input tables consumable, allowing generic sinks to work on any input. We haven't supported any kind of mutation at all since there are a lot of generic "table" types that couldn't support it.

For these kind of data processing tasks, we've been putting functionality in TableOperations.jl; there we already have a generic Tables.map, that could be used like newtbl = oldtbl |> TableOperations.map(x -> (newcol=x.oldcol,)), but that's not ideal if you have lots of columns.

So we could potentially have a dedicated oldtbl |> TableOperations.rename(:oldcol => :newcol) |> DataFrame that lazily did the column renaming. We could probably just match the API that DataFrames provides in terms of taking pairs of oldcol => newcol, or providing a whole new set of names. This should be a not-too-hard kind of exercise for whoever wanted to take a stab at it. In the mean time, I'm moving this issue to TableOperations.jl where we can discuss further.

@quinnj quinnj transferred this issue from JuliaData/Tables.jl Dec 10, 2020
@juliohm
Copy link
Author

juliohm commented Dec 11, 2020

Awesome. I will give it a try. The plan is to introduce a new table with the columns renamed. I can also try to make it lazy as suggested.

@juliohm
Copy link
Author

juliohm commented Apr 2, 2024

We now have TableTransforms.Rename, which works for Tables.jl and is actively maintained.

@juliohm juliohm closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants