Skip to content

Resampler.__iter__() not working #22365

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

Merged
merged 1 commit into from
Aug 22, 2018
Merged

Conversation

discort
Copy link
Contributor

@discort discort commented Aug 15, 2018

@@ -182,6 +182,7 @@ Other Enhancements
- :func:`to_timedelta` now supports iso-formated timedelta strings (:issue:`21877`)
- :class:`Series` and :class:`DataFrame` now support :class:`Iterable` in constructor (:issue:`2193`)
- :class:`DatetimeIndex` gained :attr:`DatetimeIndex.timetz` attribute. Returns local time with timezone information. (:issue:`21358`)
- :class:`Resampler` now is iterable (:issue:`15314`).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a note say what each item is, or make the analogy to group by. Could you also make a new subsection of the docs and link to it from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it looking good?

:class:`Resampler` now is iterable like :class:`GroupBy` (:issue:`15314`).

Could you also make a new subsection of the docs and link to it from here.

I'm not sure what do you mean here. Could you please explain a little bit?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -97,6 +97,18 @@ def __getattr__(self, attr):

return object.__getattribute__(self, attr)

def __iter__(self):
"""
Resampler iterator
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a bit more explanation here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-------
Generator yielding sequence of (name, subsetted object)
for each group
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an examples and a See Also to grouupby iter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomAugspurger

I wanted to make sure that we are on the same page. Should I add See Also section for a magic method __iter__? But it's an internal method, isn't it?

@TomAugspurger
Copy link
Contributor

TomAugspurger commented Aug 15, 2018 via email

@codecov
Copy link

codecov bot commented Aug 15, 2018

Codecov Report

Merging #22365 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22365      +/-   ##
==========================================
- Coverage   92.05%   92.05%   -0.01%     
==========================================
  Files         169      169              
  Lines       50709    50712       +3     
==========================================
+ Hits        46679    46681       +2     
- Misses       4030     4031       +1
Flag Coverage Δ
#multiple 90.45% <100%> (-0.01%) ⬇️
#single 42.25% <33.33%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/resample.py 96.1% <100%> (+0.02%) ⬆️
pandas/util/_depr_module.py 65.11% <0%> (-2.33%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84af863...475c74d. Read the comment docs.

...: print(group)
...:

It's standard Python-fu but remember you can unpack the tuple in the for loop
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it’s not very clear what this last part does here
i would remove

@jreback jreback added this to the 0.24.0 milestone Aug 16, 2018
@jreback jreback added Resample resample method Compat pandas objects compatability with Numpy or Python functions Groupby labels Aug 16, 2018
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some doc comments. ping on green.

With the Resampler object in hand, iterating through the grouped data is very
natural and functions similarly to :py:func:`itertools.groupby`:

.. ipython::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use ..ipython:: python


.. ipython::

In [1]: resampled = df.resample('H')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add the ipython prompts, they will be added during execution

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also fix the groupby.iterating example as well

Iterating through groups
------------------------

With the Resampler object in hand, iterating through the grouped data is very
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a class ref here

@@ -703,6 +703,23 @@ regularity will result in a ``DatetimeIndex``, although frequency is lost:

ts2[[0, 2, 6]].index

.. _timeseries.iterating:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a reference to the groupby.iterating section (and a reverse ref from there to here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback

I didn't find how to add a reference in the docs. Could you share how to do that?

@discort
Copy link
Contributor Author

discort commented Aug 22, 2018

@jreback

@jreback jreback merged commit 98e77e9 into pandas-dev:master Aug 22, 2018
@jreback
Copy link
Contributor

jreback commented Aug 22, 2018

thanks @discort

Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Groupby Resample resample method
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resampler.__iter__() not working
3 participants