pyspark.sql.functions.second#
- pyspark.sql.functions.second(col)[source]#
Extract the seconds of a given date as integer.
New in version 1.5.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
- col
Column
or str target date/timestamp column to work on.
- col
- Returns
Column
seconds part of the timestamp as integer.
Examples
>>> import datetime >>> df = spark.createDataFrame([(datetime.datetime(2015, 4, 8, 13, 8, 15),)], ['ts']) >>> df.select(second('ts').alias('second')).collect() [Row(second=15)]