question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support multi-dimensional grouped operations and group_over

See original GitHub issue

Multi-dimensional grouped operations should be relatively straightforward – the main complexity will be writing an N-dimensional concat that doesn’t involve repetitively copying data.

The idea with group_over would be to support groupby operations that act on a single element from each of the given groups, rather than the unique values. For example, ds.group_over(['lat', 'lon']) would let you iterate over or apply to 2D slices of ds, no matter how many dimensions it has.

Roughly speaking (it’s a little more complex for the case of non-dimension variables), ds.group_over(dims) would get translated into ds.groupby([d for d in ds.dims if d not in dims]).

Related: #266

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:15
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

7reactions
jhammancommented, Aug 17, 2015

@shoyer -

I want to look into putting a PR together for this. I’m looking for the same functionality that you get with a pandas Series or DataFrame:

data.groupby([lambda x: x.hour, lambda x: x.timetuple().tm_yday]).mean()

The motivation comes in making a Hovmoller diagram. What we need is this functionality:

da.groupby(['time.hour', 'time.dayofyear']).mean().plot()

If you can point me in the right direction, I’ll see if I can put something together.

4reactions
clarkfitzgcommented, Aug 17, 2015

For (2) I think it makes sense to extend the existing groupby to deal with multiple dimensions. Ie, let it take an iterable of dimension names.

>>> darray.groupby(['lat', 'lon'])

Then we’d have something similar to the SQL groupby, which is a good thing.

By the way, in #527 we were considering using this approach to make the faceted plots on both rows and columns.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Applying a function to a multidimensional array with grouping ...
I have a multidimensional array v[x,y,z] and I would like to apply a function to the array along the z dimension using a...
Read more >
Using groupby() and apply() over more than a single ...
I'm trying to use xarray's split-apply-combine approach for processing a 3-D dataset with dimensions: time, lon, and lat.
Read more >
ADP 3-07 - Army Publishing Directorate
Executing stability operations supports the fundamentals of stabilization. Army stability operations ... favoring one group over another.
Read more >
GroupBy: Group and Bin Data - Xarray
Group by operations work on both Dataset and DataArray objects. Most of the examples focus on grouping by a single one-dimensional variable, although...
Read more >
The impact of individual versus group rewards on work group ...
This will help managers to identify and focus attention on work group situations where the design ... as well as on the environment...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found