Comments (8)
The error message mentions: Try passing .groupby(..., squeeze=False)
which ends up working. This will be fixed once we finally make that the default. It's been warning for 7 months now.
from xarray.
Or we can fix the bug here:
Lines 812 to 818 in d0048ef
We need to raise the error for virtual variables too.
from xarray.
OK great!
(so I understand — when we change the default, would da.groupby(dim).mean()
work — i.e. with no dim passed to mean
? Or we'll still mandate a dim passed to mean? Currently da.groupby('time').mean()
fails passes but da.groupby('lat').mean()
fails, seemingly because lat
is a float index... )
from xarray.
Turns out it has to do with sortedness of lat
. We only check.is_monotonic_increasing
but yes if I pass squeeze=False
it all works.
xarray/xarray/core/groupers.py
Lines 122 to 126 in d0048ef
Could switch it to add is_monotonic_decreasing
too.
from xarray.
OK great!
So it sounds like after we make that change, it won't be required to pass any dimensions to the aggregation func — da.groupby('lat').mean()
, (with nothing passed to mean()
), will aggregate over groups along lat
without reducing any other dims. (lmk if I'm mistaken)
That'll be much better than the current state, where not passing anything to mean()
works depending on the dimension's sortedness + whether flox is installed. Notably, if we only add is_monotonically_decreasing
without making squeeze=False
the default, it'll still depend on the array sortedness.
TY!
from xarray.
Setting squeeze=False
makes it always work.
#7427 removes the dependence on sortedness. That is, once merged, it will dependably error on main
. Perhaps we should just delete the squeeze
kwarg, it's been a pain for quite long.
from xarray.
OK v nice — on #7427 this dependably works on both flox & no flox, both ordered & unordered.
with xr.set_options(use_flox=True):
print(da.assign_coords(lat=lambda x: x.lat % 2).groupby('lat', squeeze=False).sum())
from xarray.
Closed by #9280, thanks !
from xarray.
Related Issues (20)
- Splitting out lazy indexing layer and backends layer as zarr-python features HOT 3
- XArray does not support Latin characters in netCDF file names HOT 6
- Assigning `pd.Series` as a coord drops the index name, causing a confusing error
- DataTree.update can cause multiple root groups. HOT 6
- Segmentation fault similar to issue 8410 HOT 1
- Losing top level name attribute when saving and then reopening using h5netcdf HOT 15
- Segmentation fault similar to issue 8410 HOT 3
- Unloaded DataArray opened with scipy missing attributes when sliced with a sequence HOT 3
- Weighted quantile calculation is incorrect HOT 2
- Xarray now forces Pandas == 2.2.2 install HOT 4
- Calling `.isel()` on a timezone-aware dimension/index causes it to lose timezone information HOT 2
- Broken Benchmarked by ASV Badge URL HOT 1
- storing results of interpolate_na into numpy.array HOT 3
- Pandas-stubs forces numpy <2.0.0 HOT 2
- Missing coordinate attributes after weighted mean HOT 1
- ds.weighted should skip non-numeric data_vars
- Integrate Treescope into Xarray's interactive HTML repr HOT 3
- Inconsistent `run_spec` during zarr dataset opening by multiple bound methods HOT 11
- Failure on `main` testing xarray.cross HOT 2
- pickle error in Dataset.sortby() when used with file-like
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xarray.