cudf.DataFrame.last#
- DataFrame.last(offset)[source]#
Select final periods of time series data based on a date offset.
When having a DataFrame with sorted dates as index, this function can select the last few rows based on a date offset.
- Parameters:
- offset: str
The offset length of the data that will be selected. For instance, ‘3D’ will display all rows having their index within the last 3 days.
- Returns:
- Series or DataFrame
A subset of the caller.
- Raises:
- TypeError
If the index is not a
DatetimeIndex
Examples
>>> i = cudf.date_range('2018-04-09', periods=4, freq='2D') >>> ts = cudf.DataFrame({'A': [1, 2, 3, 4]}, index=i) >>> ts A 2018-04-09 1 2018-04-11 2 2018-04-13 3 2018-04-15 4 >>> ts.last('3D') A 2018-04-13 3 2018-04-15 4