PySpark SQL Functions | dayofweek method
PySpark SQL Functions'
dayofweek(~) method extracts the day of the week of each datetime value or date string of a PySpark column.
The date column from which to extract the day of the week.
Column of integers.
Consider the following PySpark DataFrame with some
Getting the day of the week from datetime values in PySpark DataFrame
To get the day of the week in PySpark DataFrame:
7represents Sunday while
we are using
alias(~)to give a label to the
Columnobject returned by
Getting the day of week from date strings in PySpark DataFrame
Note that the method still works even if the date is in string form: