-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
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
Conversation
doc/source/whatsnew/v0.24.0.txt
Outdated
@@ -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`). |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A section like http://pandas-docs.github.io/pandas-docs-travis/groupby.html#iterating-through-groups, but in doc/source/timeseries.rst
@@ -97,6 +97,18 @@ def __getattr__(self, attr): | |||
|
|||
return object.__getattribute__(self, attr) | |||
|
|||
def __iter__(self): | |||
""" | |||
Resampler iterator |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have any example? I found only for GroupBy
?
https://github.com/pandas-dev/pandas/blob/v0.23.4/pandas/core/groupby/groupby.py#L881-L890
pandas/core/resample.py
Outdated
------- | ||
Generator yielding sequence of (name, subsetted object) | ||
for each group | ||
""" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
dunder methods like __iter__ are included in the docs.
Although,
http://pandas-docs.github.io/pandas-docs-travis/generated/pandas.core.groupby.GroupBy.__iter__.html
isn't that great of a docstring at the moment :)
…On Wed, Aug 15, 2018 at 10:25 AM Alex Rychyk ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pandas/core/resample.py
<#22365 (comment)>:
> @@ -97,6 +97,18 @@ def __getattr__(self, attr):
return object.__getattribute__(self, attr)
+ def __iter__(self):
+ """
+ Resampler iterator
+
+ Returns
+ -------
+ Generator yielding sequence of (name, subsetted object)
+ for each group
+ """
@TomAugspurger <https://github.com/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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#22365 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHIkBiI0Po_UM_idqo2Lxic4DyVWDVks5uRD18gaJpZM4V95zU>
.
|
e76dc3a
to
6c21f3a
Compare
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
6c21f3a
to
00f513a
Compare
doc/source/timeseries.rst
Outdated
...: print(group) | ||
...: | ||
|
||
It's standard Python-fu but remember you can unpack the tuple in the for loop |
There was a problem hiding this comment.
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
00f513a
to
794cbc8
Compare
There was a problem hiding this 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.
doc/source/timeseries.rst
Outdated
With the Resampler object in hand, iterating through the grouped data is very | ||
natural and functions similarly to :py:func:`itertools.groupby`: | ||
|
||
.. ipython:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ..ipython:: python
doc/source/timeseries.rst
Outdated
|
||
.. ipython:: | ||
|
||
In [1]: resampled = df.resample('H') |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
doc/source/timeseries.rst
Outdated
Iterating through groups | ||
------------------------ | ||
|
||
With the Resampler object in hand, iterating through the grouped data is very |
There was a problem hiding this comment.
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
doc/source/timeseries.rst
Outdated
@@ -703,6 +703,23 @@ regularity will result in a ``DatetimeIndex``, although frequency is lost: | |||
|
|||
ts2[[0, 2, 6]].index | |||
|
|||
.. _timeseries.iterating: |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
794cbc8
to
475c74d
Compare
thanks @discort |
git diff upstream/master -u -- "*.py" | flake8 --diff