@@ -6717,25 +6717,26 @@ def at_time(self, time, asof=False):
67176717
67186718 Examples
67196719 --------
6720- >>> i = pd.date_range('2018-04-09', periods=4, freq='4D2min ')
6720+ >>> i = pd.date_range('2018-04-09', periods=4, freq='12H ')
67216721 >>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
67226722 >>> ts
67236723 A
6724- date
67256724 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 ')
67306729 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
67336732
67346733 See Also
67356734 --------
67366735 between_time : Select values between particular times of the day
67376736 first : Select initial periods of time series based on a date offset
67386737 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
67396740 """
67406741 try :
67416742 indexer = self .index .indexer_at_time (time , asof = asof )
@@ -6748,6 +6749,9 @@ def between_time(self, start_time, end_time, include_start=True,
67486749 """
67496750 Select values between particular times of the day (e.g., 9:00-9:30 AM).
67506751
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+
67516755 Notes
67526756 -----
67536757 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,
67656769
67666770 Examples
67676771 --------
6768- >>> i = pd.date_range('2018-04-09', periods=4, freq='2min ')
6772+ >>> i = pd.date_range('2018-04-09', periods=4, freq='1D20min ')
67696773 >>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
67706774 >>> ts
67716775 A
67726776 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')
67776790 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
67806793
67816794 See Also
67826795 --------
67836796 at_time : Select values at a particular time of the day
67846797 first : Select initial periods of time series based on a date offset
67856798 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
67866801 """
67876802 try :
67886803 indexer = self .index .indexer_between_time (
@@ -7046,19 +7061,25 @@ def first(self, offset):
70467061
70477062 Examples
70487063 --------
7049- >>> i = pd.date_range('2018-04-09', periods=4, freq='D ')
7064+ >>> i = pd.date_range('2018-04-09', periods=4, freq='2D ')
70507065 >>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
70517066 >>> ts
70527067 A
70537068 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+
70577075 >>> ts.first('3D')
70587076 A
70597077 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.
70627083
70637084 Returns
70647085 -------
@@ -7104,19 +7125,25 @@ def last(self, offset):
71047125
71057126 Examples
71067127 --------
7107- >>> i = pd.date_range('2018-04-09', periods=4, freq='D ')
7128+ >>> i = pd.date_range('2018-04-09', periods=4, freq='2D ')
71087129 >>> ts = pd.DataFrame({'A': [1,2,3,4]}, index=i)
71097130 >>> ts
71107131 A
71117132 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+
71157139 >>> ts.last('3D')
71167140 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.
71207147
71217148 Returns
71227149 -------
0 commit comments