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

bug(?): Polars / pandas row order in pivot differs #1641

Closed
MarcoGorelli opened this issue Dec 21, 2024 · 2 comments · Fixed by #1643
Closed

bug(?): Polars / pandas row order in pivot differs #1641

MarcoGorelli opened this issue Dec 21, 2024 · 2 comments · Fixed by #1643

Comments

@MarcoGorelli
Copy link
Member

MarcoGorelli commented Dec 21, 2024

Noticed in test_pivot_no_index from #1640, the tests fail if I remove .sort("ix", "bar")

gonna have to check this

@MarcoGorelli
Copy link
Member Author

(Pdb) df.to_native()
shape: (4, 4)
┌─────┬─────┬─────┬─────┐
│ ixcolfoobar │
│ ------------ │
│ i64stri64str │
╞═════╪═════╪═════╪═════╡
│ 1a1x   │
│ 1b2y   │
│ 2a3z   │
│ 2b4w   │
└─────┴─────┴─────┴─────┘
(Pdb) df.to_native().pivot('col', values='foo')
shape: (4, 4)
┌─────┬─────┬──────┬──────┐
│ ixbarab    │
│ ------------  │
│ i64stri64i64  │
╞═════╪═════╪══════╪══════╡
│ 1x1null │
│ 1ynull2    │
│ 2z3null │
│ 2wnull4    │
└─────┴─────┴──────┴──────┘

🤔 is Polars respecting maintain_order here? The grouped columns are 'ix' and 'bar', yet the output isn't sorted according to them

@MarcoGorelli
Copy link
Member Author

I think this wasn't quite behaving as-documented in Polars: pola-rs/polars#20403

I'm not sure we should be guaranteeing an output order at all here in Narwhals, and we should remove maintain_order

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant