Skip to content

Commit 8749273

Browse files
roycodingjreback
authored andcommitted
BUG: Fix for resampler for grouping kwarg bug
closes #13235 closes #13241
1 parent b638f18 commit 8749273

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

doc/source/whatsnew/v0.18.2.txt

+6-2
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ Bug Fixes
224224

225225

226226
- Bug in ``PeriodIndex`` and ``Period`` subtraction raises ``AttributeError`` (:issue:`13071`)
227-
- Bug in ``.resample(..)`` with a ``PeriodIndex`` not changing its ``freq`` appropriately when empty (:issue:`13067`)
228227
- Bug in ``PeriodIndex`` construction returning a ``float64`` index in some circumstances (:issue:`13067`)
228+
- Bug in ``.resample(..)`` with a ``PeriodIndex`` not changing its ``freq`` appropriately when empty (:issue:`13067`)
229229
- Bug in ``.resample(..)`` with a ``PeriodIndex`` not retaining its type or name with an empty ``DataFrame``appropriately when empty (:issue:`13212`)
230+
- Bug in ``groupby(..).resample(..)`` where passing some keywords would raise an exception (:issue:`13235`)
231+
- Bug in ``pd.read_csv`` in which the ``nrows`` argument was not properly validated for both engines (:issue:`10476`)
230232

231233

232234

@@ -251,5 +253,7 @@ Bug Fixes
251253

252254
- Bug in ``groupby`` where ``apply`` returns different result depending on whether first result is ``None`` or not (:issue:`12824`)
253255

256+
257+
258+
254259
- Bug in ``Categorical.remove_unused_categories()`` changes ``.codes`` dtype to platform int (:issue:`13261`)
255-
- Bug in ``pd.read_csv`` in which the ``nrows`` argument was not properly validated for both engines (:issue:`10476`)

pandas/tseries/resample.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,7 @@ def get_resampler_for_grouping(groupby, rule, how=None, fill_method=None,
912912
return _maybe_process_deprecations(r,
913913
how=how,
914914
fill_method=fill_method,
915-
limit=limit,
916-
**kwargs)
915+
limit=limit)
917916

918917

919918
class TimeGrouper(Grouper):

pandas/tseries/tests/test_resample.py

+20
Original file line numberDiff line numberDiff line change
@@ -2670,6 +2670,26 @@ def f(x):
26702670
result = g.apply(f)
26712671
assert_frame_equal(result, expected)
26722672

2673+
def test_resample_groupby_with_label(self):
2674+
# GH 13235
2675+
index = date_range('2000-01-01', freq='2D', periods=5)
2676+
df = DataFrame(index=index,
2677+
data={'col0': [0, 0, 1, 1, 2], 'col1': [1, 1, 1, 1, 1]}
2678+
)
2679+
result = df.groupby('col0').resample('1W', label='left').sum()
2680+
2681+
mi = [np.array([0, 0, 1, 2]),
2682+
pd.to_datetime(np.array(['1999-12-26', '2000-01-02',
2683+
'2000-01-02', '2000-01-02'])
2684+
)
2685+
]
2686+
mindex = pd.MultiIndex.from_arrays(mi, names=['col0', None])
2687+
expected = DataFrame(data={'col0': [0, 0, 2, 2], 'col1': [1, 1, 2, 1]},
2688+
index=mindex
2689+
)
2690+
2691+
assert_frame_equal(result, expected)
2692+
26732693
def test_consistency_with_window(self):
26742694

26752695
# consistent return values with window

0 commit comments

Comments
 (0)