Skip to content

Dataset.groupby summary methods #122

Closed

Description

@jhamman

This may just be a documentation issue but the summary apply and combine methods for the Dataset.GroupBy object seem to be missing.

In [146]:

foo_values = np.random.RandomState(0).rand(3, 4)
times = pd.date_range('2000-01-01', periods=3)
ds = xray.Dataset({'time': ('time', times),
                   'foo': (['time', 'space'], foo_values)})

ds.groupby('time').mean()  #replace time with time.month after #121 is adressed
# ds.groupby('time').apply(np.mean)  # also Errors here

 ---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-146-eec1e73cff23> in <module>()
      3 ds = xray.Dataset({'time': ('time', times),
      4                    'foo': (['time', 'space'], foo_values)})
----> 5 ds.groupby('time').mean()
      6 ds.groupby('time').apply(np.mean)

AttributeError: 'DatasetGroupBy' object has no attribute 'mean'

Adding this functionality, if not already present, seems like a really nice addition to the package.

Activity

  1. shoyer commented on May 12, 2014

    @shoyer
    Member

    The problem is that it's ambiguous which array you would like to summarize. I suppose we could default to using all noncoordinates? That would be similar to how pandas does its DataFrame.groupby methods.

  2. jhamman commented on May 12, 2014

    @jhamman
    MemberAuthor

    Right, although it doesn't have to be ambiguous. Why not just summarize each group along the group_dim?

  3. shoyer commented on May 12, 2014

    @shoyer
    Member

    We currently don't implement methods like ds.mean(), which it would make sense to implement before adding the groupby version. But I do think it would be perfectly consistent to say that the mean of a dataset is the dataset given by taking the mean of every variable in the dataset.

  4. added a commit that references this issue on Jun 22, 2014
    18c7b9d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions