w3resource

Pandas Series: last() function

Subsetting final periods of time in Pandas series

The last() function (convenience method ) is used to subset final periods of time series data based on a date offset.

Return a boolean Series showing whether each element in the Series matches an element in the passed sequence of values exactly.

Syntax:

Series.last(self, offset)[source]
Pandas Series last image

Parameters:

Name Description Type/Default Value Required / Optional
offset string, DateOffset
Default Value: relativedelta
Required

Returns: subset - same type as caller

Raises: TypeError
If the index is not a DatetimeIndex

Example:


Download the above Notebook from here.



Inviting useful, relevant, well-written and unique guest posts