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

DataFrame#to_wide returns wrong wide table when rows are not ordered #294

Open
heronshoes opened this issue Feb 1, 2024 · 0 comments
Open
Labels
bug Something isn't working
Milestone

Comments

@heronshoes
Copy link
Contributor

DataFrame#to_wide returns wrong wide table when rows are not ordered.

wide = DataFrame.new(
  rows: %w[row1 row2],
  Column1: [1.1, 1.2],
  Column2: [2.1, 2.2]
)
wide
=>
#<RedAmber::DataFrame : 2 x 3 Vectors, 0x00000000004422e4>
  rows      Column1  Column2
  <string> <double> <double>
0 row1          1.1      2.1
1 row2          1.2      2.2

long = wide.to_long(:rows)

=> 
#<RedAmber::DataFrame : 4 x 3 Vectors, 0x00000000004760f8>
  rows     NAME        VALUE
  <string> <string> <double>
0 row1     Column1       1.1
1 row1     Column2       2.1
2 row2     Column2       2.2
3 row2     Column1       1.2

long.to_wide == wide

=>
true

shuffled = long.shuffle
shuffle
=> 
#<RedAmber::DataFrame : 4 x 3 Vectors, 0x0000000000516850>
  rows     NAME        VALUE
  <string> <string> <double>
0 row1     Column1       1.1
1 row2     Column2       2.2
2 row2     Column1       1.2
3 row1     Column2       2.1

shuffled.to_wide
=> 
#<RedAmber::DataFrame : 2 x 3 Vectors, 0x000000000052ec84>
  rows      Column1  Column2
  <string> <double> <double>
0 row1          1.1      2.1
1 row2          2.2      1.2

shuffled.to_wide == wide
=>
false
@heronshoes heronshoes added the bug Something isn't working label Feb 1, 2024
@heronshoes heronshoes added this to the 0.5.3 milestone Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant