@@ -6717,25 +6717,26 @@ def at_time(self, time, asof=False):
6717
6717
6718
6718
Examples
6719
6719
--------
6720
- >>> i = pd.date_range('2018-04-09', periods=4, freq='4D2min ')
6720
+ >>> i = pd.date_range('2018-04-09', periods=4, freq='12H ')
6721
6721
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
6722
6722
>>> ts
6723
6723
A
6724
- date
6725
6724
2018-04-09 00:00:00 1
6726
- 2018-04-13 00:02 :00 2
6727
- 2018-04-17 00:04 :00 3
6728
- 2018-04-21 00:06 :00 4
6729
- >>> ts.at_time('0:02 ')
6725
+ 2018-04-09 12:00 :00 2
6726
+ 2018-04-10 00:00 :00 3
6727
+ 2018-04-10 12:00 :00 4
6728
+ >>> ts.at_time('12:00 ')
6730
6729
A
6731
- date
6732
- 2018-04-13 00:02: 00 2
6730
+ 2018-04-09 12:00:00 2
6731
+ 2018-04-10 12: 00:00 4
6733
6732
6734
6733
See Also
6735
6734
--------
6736
6735
between_time : Select values between particular times of the day
6737
6736
first : Select initial periods of time series based on a date offset
6738
6737
last : Select final periods of time series based on a date offset
6738
+ DatetimeIndex.indexer_at_time : Get just the index positions for
6739
+ values at particular time of the day
6739
6740
"""
6740
6741
try :
6741
6742
indexer = self .index .indexer_at_time (time , asof = asof )
@@ -6748,6 +6749,9 @@ def between_time(self, start_time, end_time, include_start=True,
6748
6749
"""
6749
6750
Select values between particular times of the day (e.g., 9:00-9:30 AM).
6750
6751
6752
+ By setting ``start_time`` to be later than ``end_time``,
6753
+ you can get the times that are *not* between the two times.
6754
+
6751
6755
Notes
6752
6756
-----
6753
6757
For this method to work, the index must to be a :class:`DatetimeIndex`
@@ -6765,24 +6769,35 @@ def between_time(self, start_time, end_time, include_start=True,
6765
6769
6766
6770
Examples
6767
6771
--------
6768
- >>> i = pd.date_range('2018-04-09', periods=4, freq='2min ')
6772
+ >>> i = pd.date_range('2018-04-09', periods=4, freq='1D20min ')
6769
6773
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
6770
6774
>>> ts
6771
6775
A
6772
6776
2018-04-09 00:00:00 1
6773
- 2018-04-09 00:02:00 2
6774
- 2018-04-09 00:04:00 3
6775
- 2018-04-09 00:06:00 4
6776
- >>> ts.between_time('0:02', '0:04')
6777
+ 2018-04-10 00:20:00 2
6778
+ 2018-04-11 00:40:00 3
6779
+ 2018-04-12 01:00:00 4
6780
+
6781
+ >>> ts.between_time('0:15', '0:45')
6782
+ A
6783
+ 2018-04-10 00:20:00 2
6784
+ 2018-04-11 00:40:00 3
6785
+
6786
+ You get the times that are *not* between two times by setting
6787
+ ``start_time`` later than ``end_time``:
6788
+
6789
+ >>> ts.between_time('0:45', '0:15')
6777
6790
A
6778
- 2018-04-09 00:02 :00 2
6779
- 2018-04-09 00:04: 00 3
6791
+ 2018-04-09 00:00 :00 1
6792
+ 2018-04-12 01: 00:00 4
6780
6793
6781
6794
See Also
6782
6795
--------
6783
6796
at_time : Select values at a particular time of the day
6784
6797
first : Select initial periods of time series based on a date offset
6785
6798
last : Select final periods of time series based on a date offset
6799
+ DatetimeIndex.indexer_between_time : Get just the index positions for
6800
+ values between particular times of the day
6786
6801
"""
6787
6802
try :
6788
6803
indexer = self .index .indexer_between_time (
@@ -7046,19 +7061,25 @@ def first(self, offset):
7046
7061
7047
7062
Examples
7048
7063
--------
7049
- >>> i = pd.date_range('2018-04-09', periods=4, freq='D ')
7064
+ >>> i = pd.date_range('2018-04-09', periods=4, freq='2D ')
7050
7065
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
7051
7066
>>> ts
7052
7067
A
7053
7068
2018-04-09 1
7054
- 2018-04-10 2
7055
- 2018-04-11 3
7056
- 2018-04-12 4
7069
+ 2018-04-11 2
7070
+ 2018-04-13 3
7071
+ 2018-04-15 4
7072
+
7073
+ Get the rows for the first 3 days:
7074
+
7057
7075
>>> ts.first('3D')
7058
7076
A
7059
7077
2018-04-09 1
7060
- 2018-04-10 2
7061
- 2018-04-11 3
7078
+ 2018-04-11 2
7079
+
7080
+ Notice the data for 3 first calender days were returned, not the first
7081
+ 3 days observed in the dataset, and therefore data for 2018-04-13 was
7082
+ not returned.
7062
7083
7063
7084
Returns
7064
7085
-------
@@ -7104,19 +7125,25 @@ def last(self, offset):
7104
7125
7105
7126
Examples
7106
7127
--------
7107
- >>> i = pd.date_range('2018-04-09', periods=4, freq='D ')
7128
+ >>> i = pd.date_range('2018-04-09', periods=4, freq='2D ')
7108
7129
>>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
7109
7130
>>> ts
7110
7131
A
7111
7132
2018-04-09 1
7112
- 2018-04-10 2
7113
- 2018-04-11 3
7114
- 2018-04-12 4
7133
+ 2018-04-11 2
7134
+ 2018-04-13 3
7135
+ 2018-04-15 4
7136
+
7137
+ Get the rows for the last 3 days:
7138
+
7115
7139
>>> ts.last('3D')
7116
7140
A
7117
- 2018-04-10 2
7118
- 2018-04-11 3
7119
- 2018-04-12 4
7141
+ 2018-04-13 3
7142
+ 2018-04-15 4
7143
+
7144
+ Notice the data for 3 last calender days were returned, not the last
7145
+ 3 observed days in the dataset. and therefore data for 2018-04-13 was
7146
+ not returned.
7120
7147
7121
7148
Returns
7122
7149
-------
0 commit comments