You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: DataFrame API skew() and kurtosis() raise UnboundLocalError when all the data is in one partition #41283
On master (d7d31e9), Series.skew() and Series.kurtosis() / kurt() in the DataFrame API (also reached through DataFrame.skew(), DataFrame.kurt() and agg('skew')) fail with UnboundLocalError: cannot access local variable 'combined_n' where it is not associated with a value when one partition holds all the values. combine_moments in dataframe/frames.py assigns combined_n only when it merges two non-empty partitions, but the final formula always reads it.
Example: to_dataframe(p | beam.Create([beam.Row(x=float(i * i)) for i in range(6)])).x.skew() fails on the default runner and on the FnApiRunner; pandas returns 0.9191843544212499 (skew) and -0.25414322711619963 (kurtosis) for the same values. With fewer than 3 values (skew) or 4 (kurtosis), or with all-equal values, the function returns before the formula, so those cases do not fail.
Expected: the same result as pandas. I plan to fix it by using the accumulated count n, which equals combined_n after every merge.
Issue Priority
Priority: 2 (default / most bugs should be filed as P2)
Activity
sohailshk commentedon Nov 13, 2026
.take-issue
Link issue apache#41283 in CHANGES.md