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

Allow unstack to take multiple columns to unstack on #2148

Closed
bkamins opened this issue Mar 9, 2020 · 3 comments
Closed

Allow unstack to take multiple columns to unstack on #2148

bkamins opened this issue Mar 9, 2020 · 3 comments
Labels
non-breaking The proposed change is not breaking reshaping
Milestone

Comments

@bkamins
Copy link
Member

bkamins commented Mar 9, 2020

See invenia/Wrangling.jl#10.

This should be worked on after #2147 is merged.

@bkamins
Copy link
Member Author

bkamins commented Mar 9, 2020

Some implementation notes to take into acount:

  • this will be tricky if we unstack SubDataFrame
  • this will be tricky if some or all values in the columns are missing (we need to decide how to handle this)

@bkamins
Copy link
Member Author

bkamins commented Feb 28, 2022

The question is if we need this functionality or the following is just enough:

julia> df = DataFrame(row=[1,1,1,1,2,2,2,2], col1=[1,1,2,2,1,1,2,2], col2=[1,2,1,2,1,2,1,2], values=1:8)
8×4 DataFrame
 Row │ row    col1   col2   values
     │ Int64  Int64  Int64  Int64
─────┼─────────────────────────────
   1 │     1      1      1       1
   2 │     1      1      2       2
   3 │     1      2      1       3
   4 │     1      2      2       4
   5 │     2      1      1       5
   6 │     2      1      2       6
   7 │     2      2      1       7
   8 │     2      2      2       8

julia> unstack(select(df, :row, [:col1, :col2] => ByRow((x,y) -> string(x, "_", y)) => :col, :values), :row, :col, :values)
2×5 DataFrame
 Row │ row    1_1     1_2     2_1     2_2
     │ Int64  Int64?  Int64?  Int64?  Int64?
─────┼───────────────────────────────────────
   1 │     1       1       2       3       4
   2 │     2       5       6       7       8

@bkamins bkamins modified the milestones: 1.x, 1.4 Feb 28, 2022
@bkamins bkamins modified the milestones: 1.4, 1.5 Jun 7, 2022
@bkamins
Copy link
Member Author

bkamins commented Dec 5, 2022

I am closing this in favor of #3237 (to have a single place to discuss all related issues)

@bkamins bkamins closed this as completed Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-breaking The proposed change is not breaking reshaping
Projects
None yet
Development

No branches or pull requests

1 participant