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.


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


Name Description Type/Default Value Required / Optional
offset Keep labels from axis which are in items. string, DateOffset
Default Value: relativedelta

Returns: subset - same type as caller

Raises: TypeError
If the index is not a DatetimeIndex


Download the Pandas Series Notebooks from here.

Previous: Test Pandas objects contain the same elements
Next: Get the first n rows in Pandas series

Share this Tutorial / Exercise on : Facebook and Twitter