@@ -758,11 +758,21 @@ natural and functions similarly to :py:func:`itertools.groupby`:
758
758
759
759
.. ipython :: python
760
760
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' )
762
771
763
772
for name, group in resampled:
764
- print (name)
765
- print (group)
773
+ print (" Group: " , name)
774
+ print (" -" * 27 )
775
+ print (group, end = " \n\n " )
766
776
767
777
See :ref: `groupby.iterating-label `.
768
778
@@ -910,26 +920,22 @@ It's definitely worth exploring the ``pandas.tseries.offsets`` module and the
910
920
various docstrings for the classes.
911
921
912
922
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.
917
926
918
927
.. ipython :: python
919
928
929
+ ts = pd.Timestamp(' 2014-01-01 09:00' )
920
930
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()
925
933
934
+ ts = pd.Timestamp(' 2014-01-01 22:00' )
926
935
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()
933
939
934
940
.. _timeseries.dayvscalendarday :
935
941
@@ -1488,6 +1494,7 @@ time. The method for this is :meth:`~Series.shift`, which is available on all of
1488
1494
the pandas objects.
1489
1495
1490
1496
.. ipython :: python
1497
+
1491
1498
ts = pd.Series(range (len (rng)), index = rng)
1492
1499
ts = ts[:5 ]
1493
1500
ts.shift(1 )
0 commit comments