pyspark.sql.functions.weekday#
- pyspark.sql.functions.weekday(col)[source]#
Returns the day of the week for date/timestamp (0 = Monday, 1 = Tuesday, …, 6 = Sunday).
New in version 3.5.0.
- Parameters
- col
Column
or str target date/timestamp column to work on.
- col
- Returns
Column
the day of the week for date/timestamp (0 = Monday, 1 = Tuesday, …, 6 = Sunday).
Examples
>>> df = spark.createDataFrame([('2015-04-08',)], ['dt']) >>> df.select(weekday('dt').alias('day')).show() +---+ |day| +---+ | 2| +---+