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 as integer. Ranges from 1 for a Sunday through to 7 for a Saturday

New in version 2.3.0.

Examples

>>> df = spark.createDataFrame([('2015-04-08',)], ['dt'])
>>> df.select(dayofweek('dt').alias('day')).collect()
[Row(day=4)]