issues: 1333514579
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1333514579 | I_kwDOAMm_X85Pe9FT | 6902 | Flox based groupby operations don't support `dtype` in mean method | 2448579 | closed | 0 | 3 | 2022-08-09T16:38:25Z | 2022-10-11T17:45:27Z | 2022-10-11T17:45:27Z | MEMBER | Discussed in https://github.com/pydata/xarray/discussions/6901
<sup>Originally posted by **tasansal** August 9, 2022</sup>
We have been using the new groupby logic with Flox and numpy_groupies; however, when we run the following, the dtype is not recognized as a valid argument.
This breaks API compatibility for cases where you may not have the acceleration libraries installed.
Not sure if this has to be upstream in
In addition to base Xarray we have the following extras installed:
Flox
numpy_groupies
Bottleneck
We do this because our data is `float32` but we want the accumulator in mean to be `float64` for accuracy.
One solution is to cast the variable to float64 before mean, which may cause a copy and spike in memory usage.
When Flox and numpy_groupies are not installed, it works as expected.
We are working with multi-dimensional time-series of weather forecast models.
```python
da = xr.load_mfdataset(...)
da.groupby("time.month").mean(dtype='float64').compute()
```
Here is the end of the traceback and it appears it is on Flox.
```shell
File "/home/altay_sansal_tgs_com/miniconda3/envs/wind-data-mos/lib/python3.10/site-packages/flox/core.py", line 786, in _aggregate
return _finalize_results(results, agg, axis, expected_groups, fill_value, reindex)
File "/home/altay_sansal_tgs_com/miniconda3/envs/wind-data-mos/lib/python3.10/site-packages/flox/core.py", line 747, in _finalize_results
finalized[agg.name] = agg.finalize(*squeezed["intermediates"], **agg.finalize_kwargs)
TypeError: <lambda>() got an unexpected keyword argument 'dtype'
```
What is the best way to handle this, maybe fix it in Flox? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6902/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
completed | 13221727 | issue |