Skip to content

Commit 22c2db1

Browse files
committed
fix resample
1 parent 23def24 commit 22c2db1

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

pandas/core/arrays/integer.py

+5
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,11 @@ def nbytes(self):
409409
def isna(self):
410410
return self._mask
411411

412+
@property
413+
def flags(self):
414+
# compat
415+
return self._data.flags
416+
412417
@property
413418
def _na_value(self):
414419
return np.nan

pandas/core/groupby/groupby.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -785,8 +785,12 @@ def _try_cast(self, result, obj, numeric_only=False):
785785
elif is_extension_array_dtype(dtype):
786786
# The function can return something of any type, so check
787787
# if the type is compatible with the calling EA.
788+
789+
# return the same type (Series) as our caller
788790
try:
789-
result = obj._values._from_sequence(result, dtype=dtype)
791+
result = result._constructor(
792+
obj._values._from_sequence(result, dtype=dtype),
793+
index=result.index, name=result.name)
790794
except Exception:
791795
# https://github.com/pandas-dev/pandas/issues/22850
792796
# pandas has no control over what 3rd-party ExtensionArrays
@@ -1276,6 +1280,8 @@ def f(self, **kwargs):
12761280
except Exception:
12771281
result = self.aggregate(
12781282
lambda x: npfunc(x, axis=self.axis))
1283+
1284+
result = self._try_cast(result, self.obj)
12791285
if _convert:
12801286
result = result._convert(datetime=True)
12811287
return result

pandas/tests/resample/test_datetime_index.py

+5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,11 @@ def test_resample_integerarray():
112112
dtype="Int64")
113113
assert_series_equal(result, expected)
114114

115+
result = ts.resample('3T').mean()
116+
expected = Series([1.0, 4, 7],
117+
index=pd.date_range('1/1/2000', periods=3, freq='3T'))
118+
assert_series_equal(result, expected)
119+
115120

116121
def test_resample_basic_grouper(series):
117122
s = series

0 commit comments

Comments
 (0)