Skip to content

Commit a70f86d

Browse files
committed
Fixed resample __iter__
1 parent 2e76e84 commit a70f86d

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

doc/source/timeseries.rst

+24-17
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,21 @@ natural and functions similarly to :py:func:`itertools.groupby`:
758758

759759
.. ipython:: python
760760
761-
resampled = df.resample('H')
761+
small = pd.Series(
762+
range(6),
763+
index=pd.to_datetime(['2017-01-01T00:00:00',
764+
'2017-01-01T00:30:00',
765+
'2017-01-01T00:31:00',
766+
'2017-01-01T01:00:00',
767+
'2017-01-01T03:00:00',
768+
'2017-01-01T03:05:00'])
769+
)
770+
resampled = small.resample('H')
762771
763772
for name, group in resampled:
764-
print(name)
765-
print(group)
773+
print("Group: ", name)
774+
print("-" * 27)
775+
print(group, end="\n\n")
766776
767777
See :ref:`groupby.iterating-label`.
768778

@@ -910,26 +920,22 @@ It's definitely worth exploring the ``pandas.tseries.offsets`` module and the
910920
various docstrings for the classes.
911921

912922
These operations (``apply``, ``rollforward`` and ``rollback``) preserve time
913-
(hour, minute, etc) information by default. To reset time, use ``normalize=True``
914-
when creating the offset instance. If ``normalize=True``, the result is
915-
normalized after the function is applied.
916-
923+
(hour, minute, etc) information by default. To reset time, use ``normalize``
924+
before or after applying the operation (depending on whether you want the
925+
time information included in the operation.
917926

918927
.. ipython:: python
919928
929+
ts = pd.Timestamp('2014-01-01 09:00')
920930
day = Day()
921-
day.apply(pd.Timestamp('2014-01-01 09:00'))
922-
923-
day = Day(normalize=True)
924-
day.apply(pd.Timestamp('2014-01-01 09:00'))
931+
day.apply(ts)
932+
day.apply(ts).normalize()
925933
934+
ts = pd.Timestamp('2014-01-01 22:00')
926935
hour = Hour()
927-
hour.apply(pd.Timestamp('2014-01-01 22:00'))
928-
929-
hour = Hour(normalize=True)
930-
hour.apply(pd.Timestamp('2014-01-01 22:00'))
931-
hour.apply(pd.Timestamp('2014-01-01 23:00'))
932-
936+
hour.apply(ts)
937+
hour.apply(ts).normalize()
938+
hour.apply(pd.Timestamp("2014-01-01 23:30")).normalize()
933939
934940
.. _timeseries.dayvscalendarday:
935941

@@ -1488,6 +1494,7 @@ time. The method for this is :meth:`~Series.shift`, which is available on all of
14881494
the pandas objects.
14891495

14901496
.. ipython:: python
1497+
14911498
ts = pd.Series(range(len(rng)), index=rng)
14921499
ts = ts[:5]
14931500
ts.shift(1)

0 commit comments

Comments
 (0)