w3resource

Pandas Series: first() function

Subset initial periods of Pandas time series

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

Syntax:

Series.first(self, offset)
Pandas Series first image

Parameters:

Name Description Type/Default Value Required / Optional
offset Keep labels from axis which are in items. 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