polars.Series.dt.quarter#
- Series.dt.quarter() Series [source]#
Extract quarter from underlying Date representation.
Applies to Date and Datetime columns.
Returns the quarter ranging from 1 to 4.
- Returns:
- Series
Series of data type
UInt32
.
Examples
>>> from datetime import datetime >>> start = datetime(2001, 1, 1) >>> stop = datetime(2001, 4, 1) >>> date = pl.date_range(start, stop, interval="1mo", eager=True) >>> date shape: (4,) Series: 'date' [datetime[μs]] [ 2001-01-01 00:00:00 2001-02-01 00:00:00 2001-03-01 00:00:00 2001-04-01 00:00:00 ] >>> date.dt.quarter() shape: (4,) Series: 'date' [u32] [ 1 1 1 2 ]