Description
Code Sample, a copy-pastable example if possible
code diff to reproduce the issue
diff --git a/pandas/core/resample.py b/pandas/core/resample.py
index 4a3625b2d..c82382f96 100644
--- a/pandas/core/resample.py
+++ b/pandas/core/resample.py
@@ -1043,7 +1043,7 @@ class PeriodIndexResampler(DatetimeIndexResampler):
if is_subperiod(ax.freq, self.freq):
# Downsampling
- return self._groupby_and_aggregate(how, grouper=self.grouper)
+ return self._groupby_and_aggregate(how, grouper=self.grouper, **kwargs)
elif is_superperiod(ax.freq, self.freq):
if how == 'ohlc':
# GH #13083
@@ -1051,7 +1051,7 @@ class PeriodIndexResampler(DatetimeIndexResampler):
# for pure aggregating/reducing methods
# OHLC reduces along the time dimension, but creates multiple
# values for each period -> handle by _groupby_and_aggregate()
- return self._groupby_and_aggregate(how, grouper=self.grouper)
+ return self._groupby_and_aggregate(how, grouper=self.grouper, **kwargs)
return self.asfreq()
elif ax.freq == self.freq:
return self.asfreq()
Problem description
During work on the solution of #15023 I found that when I pass kwargs
to _groupby_and_aggregate
the TestPeriodIndex::test_resample_empty_dataframe
is failed.
@jreback suggested to create a separate issue for that here
trace:
self = <pandas.core.groupby.generic.DataFrameGroupBy object at 0x106674198>, func = 'var', args = (), kwargs = {'ddof': 1}
@Appender(_apply_docs['template']
.format(input="dataframe",
examples=_apply_docs['dataframe_examples']))
def apply(self, func, *args, **kwargs):
func = self._is_builtin_func(func)
# this is needed so we don't try and wrap strings. If we could
# resolve functions to their callable functions prior, this
# wouldn't be needed
if args or kwargs:
if callable(func):
@wraps(func)
def f(g):
with np.errstate(all='ignore'):
return func(g, *args, **kwargs)
else:
> raise ValueError('func must be a callable if args or '
'kwargs are supplied')
E ValueError: func must be a callable if args or kwargs are supplied
Expected Output
TestPeriodIndex::test_resample_empty_dataframe
shouldn't be failed cause I correctly passing kwargs
to Resampler._groupby_and_aggregate
.
Output of pd.show_versions()
INSTALLED VERSIONS
commit: 1ea9664
python: 3.5.3.candidate.1
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.0.dev0+465.g1ea9664db.dirty
pytest: 3.3.2
pip: 18.0
setuptools: 33.1.1
Cython: 0.28.4
numpy: 1.12.0
scipy: None
pyarrow: None
xarray: None
IPython: 5.2.2
sphinx: 1.6.6
patsy: None
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.0
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.5
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None