pyspark.sql.functions.minute

pyspark.sql.functions.minute(col: ColumnOrName) → pyspark.sql.column.Column[source]

Extract the minutes of a given timestamp as integer.

New in version 1.5.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters
colColumn or str

target date/timestamp column to work on.

Returns
Column

minutes part of the timestamp as integer.

Examples

>>> import datetime
>>> df = spark.createDataFrame([(datetime.datetime(2015, 4, 8, 13, 8, 15),)], ['ts'])
>>> df.select(minute('ts').alias('minute')).collect()
[Row(minute=8)]