pyspark.sql.functions.dayofweek

pyspark.sql.functions.dayofweek(col)[source]

Extract the day of the week of a given date as integer.

New in version 2.3.0.

Examples

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