to_timestamp_ntz
Analyse le timestamp avec le format vers un Timestamp sans fuseau horaire. Renvoie la valeur nulle en cas d'entrée non valide.
Syntaxe
Python
from pyspark.sql import functions as dbf
dbf.to_timestamp_ntz(timestamp=<timestamp>, format=<format>)
parameter
parameter | Type | Description |
|---|---|---|
|
| Colonne d'entrée ou chaînes de caractères. |
|
| format à utiliser pour convertir les valeurs timestamp de type |
Exemples
Python
from pyspark.sql import functions as dbf
df = spark.createDataFrame([('2015-04-08 12:12:12',)], ['ts'])
df.select('*', dbf.to_timestamp_ntz('ts')).show()
df = spark.createDataFrame([('2016-12-31',)], ['dt'])
df.select('*', dbf.to_timestamp_ntz(df.dt, dbf.lit('yyyy-MM-dd'))).show()
df = spark.createDataFrame(
[('2015-04-08', 'yyyy-MM-dd'), ('2025+01+09', 'yyyy+MM+dd')], ['dt', 'fmt'])
df.select('*', dbf.to_timestamp_ntz('dt', 'fmt')).show()