-
Notifications
You must be signed in to change notification settings - Fork 177
feat(expr-ir): Support DataFrame.pivot
#3373
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
Merged
Merged
Changes from 47 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
9542273
refactor: Move compatibility flags
dangotbanned f4b5778
feat(DRAFT): Start adding `ArrowDataFrame.pivot`
dangotbanned b96f9b2
feat(DRAFT): Handle `unnest`-ing the struct column
dangotbanned 42e76db
feat(DRAFT): Add most of `DataFrame.pivot`
dangotbanned 366e951
add the bits that work so far
dangotbanned efea337
test: start adding `pivot_test`
dangotbanned 0dde622
test: Add example from docstring
dangotbanned 2c69502
fix: Support multiple index columns
dangotbanned 4079b74
feat: Support `ArrowDataFrame.pivot(values: list[str])`
dangotbanned 3bd4e50
to-done
dangotbanned 2091c91
test: Add most of the remaining tests
dangotbanned 86469e4
test: Add all remaining tests
dangotbanned c1f86e4
test: Remove aggregation from `sort_columns` tests
dangotbanned 8761c7c
feat: Support `DataFrame.pivot(sort_columns=True)`
dangotbanned aac49f8
test: Use fixtures instead of globals
dangotbanned cac30bc
test: Split up `test_pivot_on_multiple_names_out`
dangotbanned e298c06
test: Use more distinct names/values
dangotbanned 1981613
test: Make `.columns`-only tests more visible
dangotbanned 2e54da3
test: 🧹🧹🧹
dangotbanned 8194b49
feat(DRAFT): Support `pivot(on: list[str], values: str)`
dangotbanned 7d20578
oops, didn't mean to commit that
dangotbanned 9795db8
"fix" `concat_str` typing
dangotbanned 46d6a1d
fix: Short-circuit correctly in `sort` fastpath
dangotbanned 7c77975
cov
dangotbanned 30a118b
feat: Support `DataFrame.pivot(on: list[str], values: list[str])`
dangotbanned 76fbe74
docs: Explain the funky stuff
dangotbanned 4941455
refactor: Move cast->collect into `options.pivot_wider`
dangotbanned 8e59131
todos
dangotbanned 25c0b40
feat: Support `ArrowDataFrame.pivot_agg(on: str)`
dangotbanned b3d8c73
refactor: Add a dedicated `acero` wrapper
dangotbanned 90c2132
feat: Support `ArrowDataFrame.pivot_agg(on: list[str])`
dangotbanned 2fc1f05
refactor: Align `pivot_agg`, `pivot_on_multiple` a bit
dangotbanned 8f998d5
refactor: Always pass down `on_columns` as a dataframe
dangotbanned f922fbf
refactor: Align unnest/renaming
dangotbanned ca8dea9
refactor: Temp move stuff to a common function
dangotbanned 4078e8f
refactor: factor-in `pivot_on_single`
dangotbanned bc1396a
refactor: factor-in `pivot_on_multiple`
dangotbanned 3b9b454
test: Split out `assert_names_match_polars`
dangotbanned 62d3190
test: Port tests, discover new edge case
dangotbanned 27e6600
refactor: Replace `implode -> index -> explode` w/ `index -> join`
dangotbanned 8aa70e7
refactor: Fiddle some more
dangotbanned 3797d8c
be stricter than pyarrow
dangotbanned 10f3be3
test: xfail for older `pyarrow`
dangotbanned d97631b
ugh import
dangotbanned c74644f
test: Is `(15, 0, 1)` not less than `(20,)`?
dangotbanned 993c98b
ah, they were conflicting marks!
dangotbanned 65f3f37
Apply suggestions from code review
dangotbanned 8cec922
refactor: Fully merge `pivot`, `pivot_agg` into 1 method
dangotbanned dabb266
perf: Huge simplify unnest/rename
dangotbanned 6dec38b
doc, tidy, etc
dangotbanned d6a2c06
refactor: Just move everything to its own module
dangotbanned c4077d2
tweak renaming
dangotbanned e24c44a
refactor: mnove options too
dangotbanned 211581b
test: Steal test from polars instead
dangotbanned 58c985b
test: oof, what do we have here then
dangotbanned 6f0a9c1
start adding `on_columns: Self`
dangotbanned 90c238d
test: Cover errors in `on_columns: Series | DataFrame`
dangotbanned ad93dbb
test: Mark as a `pyarrow` bug
dangotbanned fc2e124
chore: Remove note
dangotbanned 8b15f12
chore: document and cover wider type support
dangotbanned 852c541
perf: Generate column names in a single `concat_str`
dangotbanned 3d046a2
refactor: Revert `concat_str` changes, do weird bits inline
dangotbanned 6392caa
docs: Link to `pyarrow` issue
dangotbanned 859ae00
Merge branch 'oh-nodes' into expr-ir/pivot
dangotbanned File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """Flags for features not available in all supported `pyarrow` versions.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Final | ||
|
|
||
| from narwhals._utils import Implementation | ||
|
|
||
| BACKEND_VERSION = Implementation.PYARROW._backend_version() | ||
| """Static backend version for `pyarrow`.""" | ||
|
|
||
| RANK_ACCEPTS_CHUNKED: Final = BACKEND_VERSION >= (14,) | ||
|
|
||
| HAS_FROM_TO_STRUCT_ARRAY: Final = BACKEND_VERSION >= (15,) | ||
| """`pyarrow.Table.{from,to}_struct_array` added in https://github.com/apache/arrow/pull/38520""" | ||
|
|
||
|
|
||
| TABLE_RENAME_ACCEPTS_DICT: Final = BACKEND_VERSION >= (17,) | ||
|
|
||
| TAKE_ACCEPTS_TUPLE: Final = BACKEND_VERSION >= (18,) | ||
|
|
||
| HAS_STRUCT_TYPE_FIELDS: Final = BACKEND_VERSION >= (18,) | ||
| """`pyarrow.StructType.fields` added in https://github.com/apache/arrow/pull/43481""" | ||
|
|
||
| HAS_SCATTER: Final = BACKEND_VERSION >= (20,) | ||
| """`pyarrow.compute.scatter` added in https://github.com/apache/arrow/pull/44394""" | ||
|
|
||
| HAS_KURTOSIS_SKEW = BACKEND_VERSION >= (20,) | ||
| """`pyarrow.compute.{kurtosis,skew}` added in https://github.com/apache/arrow/pull/45677""" | ||
|
|
||
| HAS_PIVOT_WIDER = BACKEND_VERSION >= (20,) | ||
| """`pyarrow.compute.pivot_wider` added in https://github.com/apache/arrow/pull/45562""" | ||
|
|
||
| HAS_ARANGE: Final = BACKEND_VERSION >= (21,) | ||
| """`pyarrow.arange` added in https://github.com/apache/arrow/pull/46778""" | ||
|
|
||
| TO_STRUCT_ARRAY_ACCEPTS_EMPTY: Final = BACKEND_VERSION >= (21,) | ||
| """`pyarrow.Table.to_struct_array` fixed in https://github.com/apache/arrow/pull/46357""" | ||
|
|
||
| HAS_ZFILL: Final = BACKEND_VERSION >= (21,) | ||
| """`pyarrow.compute.utf8_zero_fill` added in https://github.com/apache/arrow/pull/46815""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.