pyspark.sql.functions.dayofweek¶
- 
pyspark.sql.functions.dayofweek(col: ColumnOrName) → pyspark.sql.column.Column[source]¶ Extract the day of the week of a given date/timestamp as integer. Ranges from 1 for a Sunday through to 7 for a Saturday
New in version 2.3.0.
Changed in version 3.4.0: Supports Spark Connect.
- Parameters
 - col
Columnor str target date/timestamp column to work on.
- col
 - Returns
 Columnday of the week for given date/timestamp as integer.
Examples
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt']) >>> df.select(dayofweek('dt').alias('day')).collect() [Row(day=4)]