Skip to content

Commit 66550b1

Browse files
committed
fixed args on df
1 parent cbb6b82 commit 66550b1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-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

+7
Original file line numberDiff line numberDiff line change
@@ -2179,6 +2179,13 @@ def f(data, add_arg):
21792179
expected = self.series.resample('D').mean().multiply(multiplier)
21802180
tm.assert_series_equal(result, expected)
21812181

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

21832190
class TestPeriodIndex(Base):
21842191
_index_factory = lambda x: period_range

0 commit comments

Comments
 (0)