pyspark.sql.functions.to_timestamp_ntz#

pyspark.sql.functions.to_timestamp_ntz(timestamp, format=None)[source]#

Parses the timestamp with the format to a timestamp without time zone. Returns null with invalid input.

New in version 3.5.0.

Parameters
timestampColumn or str

Input column or strings.

formatColumn or str, optional

format to use to convert type TimestampNTZType timestamp values.

Examples

>>> df = spark.createDataFrame([("2016-04-08",)], ["e"])
>>> df.select(to_timestamp_ntz(df.e, lit("yyyy-MM-dd")).alias('r')).collect()
... 
[Row(r=datetime.datetime(2016, 4, 8, 0, 0))]
>>> df = spark.createDataFrame([("2016-04-08",)], ["e"])
>>> df.select(to_timestamp_ntz(df.e).alias('r')).collect()
... 
[Row(r=datetime.datetime(2016, 4, 8, 0, 0))]