Skip to content
forked from pydata/xarray

Commit

Permalink
Don't skip for resampling
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jan 3, 2024
1 parent d7be352 commit 33c8033
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion xarray/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,9 @@ def group_as_index(self) -> pd.Index:

@property
def can_squeeze(self) -> bool:
is_resampler = isinstance(self.grouper, TimeResampleGrouper)
is_dimension = self.group.dims == (self.group.name,)
return is_dimension and self.is_unique_and_monotonic
return not is_resampler and is_dimension and self.is_unique_and_monotonic


@dataclass
Expand Down
4 changes: 4 additions & 0 deletions xarray/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -1786,6 +1786,10 @@ def test_resample_first(self):
times = pd.date_range("2000-01-01", freq="6h", periods=10)
array = DataArray(np.arange(10), [("time", times)])

# resample to same frequency
actual = array.resample(time="6h").first()
assert_identical(array, actual)

actual = array.resample(time="1D").first()
expected = DataArray([0, 4, 8], [("time", times[::4])])
assert_identical(expected, actual)
Expand Down

0 comments on commit 33c8033

Please sign in to comment.