Skip to content

Commit 547d2a5

Browse files
committed
fixed args on df
1 parent 553a68e commit 547d2a5

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pandas/core/resample.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def __init__(self, obj, *args, **kwargs):
855855
self._groupby.grouper.mutated = True
856856
self.groupby = copy.copy(parent.groupby)
857857

858-
def _apply(self, f, *args, **kwargs):
858+
def _apply(self, f, grouper=None, *args, **kwargs):
859859
"""
860860
dispatch to _upsample; we are stripping all of the _upsample kwargs and
861861
performing the original function call on the grouped object
@@ -867,7 +867,7 @@ def func(x):
867867
if isinstance(f, compat.string_types):
868868
return getattr(x, f)(**kwargs)
869869

870-
return x.apply(f, **kwargs)
870+
return x.apply(f, *args, **kwargs)
871871

872872
result = self._groupby.apply(func)
873873
return self._wrap_result(result)

pandas/tests/test_resample.py

+8
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,7 @@ def test_resample_datetime_values(self):
21662166
tm.assert_series_equal(res, exp)
21672167

21682168
def test_resample_apply_with_additional_args(self):
2169+
# GH 14615
21692170
def f(data, add_arg):
21702171
return np.mean(data) * add_arg
21712172

@@ -2179,6 +2180,13 @@ def f(data, add_arg):
21792180
expected = self.series.resample('D').mean().multiply(multiplier)
21802181
tm.assert_series_equal(result, expected)
21812182

2183+
# Testing dataframe
2184+
df = pd.DataFrame({"A": 1, "B": 2},
2185+
index=pd.date_range('2017', periods=10))
2186+
result = df.groupby("A").resample("D").agg(f, multiplier)
2187+
expected = df.groupby("A").resample('D').mean().multiply(multiplier)
2188+
assert_frame_equal(result, expected)
2189+
21822190

21832191
class TestPeriodIndex(Base):
21842192
_index_factory = lambda x: period_range

0 commit comments

Comments
 (0)