Closed
Description
Code Sample, a copy-pastable example if possible
for i, k in df.resample('W-MON'):
print(i, k)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-60-5ca9218261db> in <module>()
----> 1 for i, k in df.resample('W-MON'):
2 print(i, k)
3 break
/xxx/lib/python3.5/site-packages/pandas/core/groupby.py in __iter__(self)
629 for each group
630 """
--> 631 return self.grouper.get_iterator(self.obj, axis=self.axis)
632
633 @Substitution(name='groupby')
AttributeError: 'NoneType' object has no attribute 'get_iterator'
Problem description
can't iterate the resampler's key and grouped dataframe
Expected Output
iterate the resampler's key and the grouped dataframe, now workaround
for key in df.resample('W-MON').groups.keys():
try:
print(key, df.resample('W-MON').get_group(key))
except KeyError:
continue
Output of pd.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_GB.UTF-8
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 30.2.0
Cython: 0.25.2
numpy: 1.12.0
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: 2.4.1
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None
update the workaround a bit