pyspark.sql.functions.make_date#

pyspark.sql.functions.make_date(year, month, day)[source]#

Returns a column with a date built from the year, month and day columns.

Added in version 3.3.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:
yearColumn or column name

The year to build the date. A column that evaluates to an integer.

monthColumn or column name

The month to build the date. A column that evaluates to an integer.

dayColumn or column name

The day to build the date. A column that evaluates to an integer.

Returns:
Column

a date built from given parts. Returns a column that evaluates to a date.

Examples

>>> from pyspark.sql import functions as sf
>>> df = spark.createDataFrame([(2020, 6, 26)], ['Y', 'M', 'D'])
>>> df.select('*', sf.make_date(df.Y, 'M', df.D)).show()
+----+---+---+------------------+
|   Y|  M|  D|make_date(Y, M, D)|
+----+---+---+------------------+
|2020|  6| 26|        2020-06-26|
+----+---+---+------------------+