Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add how=count option to resample #1328

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions xarray/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,9 @@ def resample(self, freq, dim, how='mean', skipna=None, closed=None,
a function that can be called like ``how(values, axis)`` to reduce
ndarray values along the given axis. Valid choices that can be
provided as a string include all the usual Dataset/DataArray
aggregations (``all``, ``any``, ``argmax``, ``argmin``, ``max``,
``mean``, ``median``, ``min``, ``prod``, ``sum``, ``std`` and
``var``), as well as ``first`` and ``last``.
aggregations (``all``, ``any``, ``argmax``, ``argmin``, ``count``,
``max``, ``mean``, ``median``, ``min``, ``prod``, ``sum``, ``std``
and ``var``), as well as ``first`` and ``last``.
skipna : bool, optional
Whether to skip missing values when aggregating in downsampling.
closed : 'left' or 'right', optional
Expand Down Expand Up @@ -606,6 +606,8 @@ def resample(self, freq, dim, how='mean', skipna=None, closed=None,
f = getattr(gb, how)
if how in ['first', 'last']:
result = f(skipna=skipna, keep_attrs=keep_attrs)
elif how == 'count':
result = f(dim=dim.name, keep_attrs=keep_attrs)
else:
result = f(dim=dim.name, skipna=skipna, keep_attrs=keep_attrs)
else:
Expand Down