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