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

   ### What happened?
   
   With `skipna=False`, `var()`, `std()`, `skew()` and `kurt()` on a deferred 
Series should give NaN when the data has a missing value, like pandas. Beam 
returns a number instead when the NaN is in a partition together with other 
values:
   
   ```python
   import numpy as np
   import pandas as pd
   import apache_beam as beam
   from apache_beam.dataframe.transforms import DataframeTransform
   
   parts = [
       pd.DataFrame({'x': [1.0, np.nan, 3.0]}),
       pd.DataFrame({'x': [4.0, 10.0]}, index=[3, 4]),
   ]
   
   with beam.Pipeline() as p:
     _ = (
         p | beam.Create(parts)
         | DataframeTransform(
             lambda df: df.x.var(skipna=False),
             proxy=parts[0].iloc[:0],
             yield_elements='pandas')
         | beam.Map(print))
   # pandas gives nan, Beam gives 14.883333333333335
   ```
   
   `std`, `skew` and `kurt` behave the same, and so do 
`DataFrame.var(skipna=False)` and `DataFrame.std(skipna=False)`. Seen on 2.77.0 
and on master.
   
   The partition moments in `DeferredSeries.var`, `skew` and `kurtosis` come 
from pandas `std`, `sum` and `mean`, which skip NaN, while the row count 
includes it. With `skipna=True` the NaN rows are dropped first, so only 
`skipna=False` is affected.
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [x] Component: Python SDK
   


-- 
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