Skip to content

Commit 179eaf7

Browse files
committed
Update code
1 parent 79a11be commit 179eaf7

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

narwhals-python/universal_processing.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,12 @@ def universal_pivot_v1(df: IntoFrameT) -> IntoFrameT:
4545

4646

4747
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-
)
48+
df = nw.from_native(df)
49+
if isinstance(df, nw.LazyFrame):
50+
df = df.collect()
51+
return df.pivot(
52+
on="party_name",
53+
index="century",
54+
values="last_name",
55+
aggregate_function="count",
56+
).to_native()

0 commit comments

Comments
 (0)