Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resampler.__iter__() not working #15314

DeoLeung opened this issue Feb 6, 2017 · 2 comments


None yet
2 participants
Copy link

commented Feb 6, 2017

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/ in __iter__(self)
    629         for each group
    630         """
--> 631         return self.grouper.get_iterator(self.obj, axis=self.axis)
    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():
    print(key, df.resample('W-MON').get_group(key))
  except KeyError:

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 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


This comment has been minimized.

Copy link

commented Feb 6, 2017

this was never implemented; I suppose it could for compat. If you'd like to put up a PR would be fine. Needs tests, and the impl described above will not work very well, need to do it similar to how groupby works.

@jreback jreback added this to the Next Major Release milestone Feb 6, 2017


This comment has been minimized.

Copy link

commented Feb 6, 2017

good, will have a try this weekend if I can figure it out

also the doc shall be updated, it's pointed to the groupby iter

@discort discort referenced this issue Aug 15, 2018


Resampler.__iter__() not working #22365

4 of 4 tasks complete

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Aug 16, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.