Skip to content

Commit 3a28b61

Browse files
author
Joe Hamman
authored
use pandas Grouper instead of TimeGrouper (#1767)
1 parent c2b205f commit 3a28b61

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

doc/whats-new.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ v0.10.1 (unreleased)
2121
Enhancements
2222
~~~~~~~~~~~~
2323

24-
- :py:func:`~plot.contourf()` learned to contour 2D variables that have both a 1D co-ordinate (e.g. time) and a 2D co-ordinate (e.g. depth as a function of time).
24+
- :py:func:`~plot.contourf()` learned to contour 2D variables that have both a
25+
1D co-ordinate (e.g. time) and a 2D co-ordinate (e.g. depth as a function of
26+
time) (:issue:`1737`).
2527
By `Deepak Cherian <https://github.com/dcherian>`_.
28+
- Use ``pandas.Grouper`` class in xarray resample methods rather than the
29+
deprecated ``pandas.TimeGrouper`` class (:issue:`1766`).
30+
By `Joe Hamman <https://github.com/jhamman>`_.
2631

2732

2833
Bug fixes

xarray/core/common.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -590,10 +590,9 @@ def resample(self, freq=None, dim=None, how=None, skipna=None,
590590
raise TypeError("Dimension name should be a string; "
591591
"was passed %r" % dim)
592592
group = DataArray(dim, [(dim.dims, dim)], name=RESAMPLE_DIM)
593-
time_grouper = pd.TimeGrouper(freq=freq, closed=closed,
594-
label=label, base=base)
593+
grouper = pd.Grouper(freq=freq, closed=closed, label=label, base=base)
595594
resampler = self._resample_cls(self, group=group, dim=dim_name,
596-
grouper=time_grouper,
595+
grouper=grouper,
597596
resample_dim=RESAMPLE_DIM)
598597

599598
return resampler
@@ -615,9 +614,9 @@ def _resample_immediately(self, freq, dim, how, skipna,
615614
if isinstance(dim, basestring):
616615
dim = self[dim]
617616
group = DataArray(dim, [(dim.dims, dim)], name=RESAMPLE_DIM)
618-
time_grouper = pd.TimeGrouper(freq=freq, how=how, closed=closed,
619-
label=label, base=base)
620-
gb = self._groupby_cls(self, group, grouper=time_grouper)
617+
grouper = pd.Grouper(freq=freq, how=how, closed=closed, label=label,
618+
base=base)
619+
gb = self._groupby_cls(self, group, grouper=grouper)
621620
if isinstance(how, basestring):
622621
f = getattr(gb, how)
623622
if how in ['first', 'last']:

0 commit comments

Comments
 (0)