We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 79a11be commit 179eaf7Copy full SHA for 179eaf7
narwhals-python/universal_processing.py
@@ -45,15 +45,12 @@ def universal_pivot_v1(df: IntoFrameT) -> IntoFrameT:
45
46
47
def universal_pivot_v2(df: IntoFrameT) -> IntoFrameT:
48
- if isinstance(nw.from_native(df), nw.LazyFrame):
49
- df = nw.from_native(df).collect()
50
- return (
51
- nw.from_native(df)
52
- .pivot(
53
- on="party_name",
54
- index="century",
55
- values="last_name",
56
- aggregate_function="count",
57
- )
58
- .to_native()
59
+ df = nw.from_native(df)
+ if isinstance(df, nw.LazyFrame):
+ df = df.collect()
+ return df.pivot(
+ on="party_name",
+ index="century",
+ values="last_name",
+ aggregate_function="count",
+ ).to_native()
0 commit comments