Skip to content

Commit 33c8033

Browse files
committed
Don't skip for resampling
1 parent d7be352 commit 33c8033

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

xarray/core/groupby.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,9 @@ def group_as_index(self) -> pd.Index:
414414

415415
@property
416416
def can_squeeze(self) -> bool:
417+
is_resampler = isinstance(self.grouper, TimeResampleGrouper)
417418
is_dimension = self.group.dims == (self.group.name,)
418-
return is_dimension and self.is_unique_and_monotonic
419+
return not is_resampler and is_dimension and self.is_unique_and_monotonic
419420

420421

421422
@dataclass

xarray/tests/test_groupby.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,6 +1786,10 @@ def test_resample_first(self):
17861786
times = pd.date_range("2000-01-01", freq="6h", periods=10)
17871787
array = DataArray(np.arange(10), [("time", times)])
17881788

1789+
# resample to same frequency
1790+
actual = array.resample(time="6h").first()
1791+
assert_identical(array, actual)
1792+
17891793
actual = array.resample(time="1D").first()
17901794
expected = DataArray([0, 4, 8], [("time", times[::4])])
17911795
assert_identical(expected, actual)

0 commit comments

Comments
 (0)