sohailshk opened a new issue, #41283:
URL: https://github.com/apache/beam/issues/41283

   ### What happened?
   
   On master (d7d31e96923), `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)
   
   ### Issue Components
   
   - [x] Component: Python SDK
   - [ ] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [ ] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to