anishmehta24 opened a new pull request, #41948:
URL: https://github.com/apache/beam/pull/41948

   Fixes #41947
   
   `mean()` and `std()` failed on datetime64 and timedelta64 Series. `mean` 
divides `sum()` by `count()`, so datetimes raise (no sum) and the timedelta 
proxy hits `Timedelta(0) / 0`. `std` goes through `var`, which squares a 
Timedelta. pandas computes both on the values as floats in the unit of the 
dtype and truncates the result back to that unit. Now `mean` and `std` do the 
same: they convert the values to floats, use the existing float `mean` and 
`std`, and turn the result back into a Timestamp or Timedelta. 
`DataFrame.mean/std(numeric_only=False)` and `agg(['mean', 'std'])` on these 
columns go through the same methods, so they work too.
   
   Added `test_mean_and_std_datetimelike` to frames_test.py. It fails on 
master. The apache_beam/dataframe tests and the Series, DataFrame, NDFrame, 
datetime and GroupBy pandas doctests pass.
   


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

  • [PR] [Python] Fix DataFrame me... anishmehta24 (via GitHub) via github

Reply via email to