pyspark.sql.functions.timestamp_seconds

pyspark.sql.functions。 timestamp_seconds ( 上校:ColumnOrName )→pyspark.sql.column.Column

轉換從Unix新紀元的秒數(1970 - 01 - 01 - t00:00:00z)到一個時間戳。

例子

> > >pyspark.sql.functions進口timestamp_seconds> > >火花相依(“spark.sql.session.timeZone”,“UTC”)> > >time_df=火花createDataFrame(((1230219000),(“unix_time”])> > >time_df選擇(timestamp_seconds(time_dfunix_time)別名(“t”))顯示()+ - - - - - - - - - - - - - - - - - - - +| ts |+ - - - - - - - - - - - - - - - - - - - +| 2008-12-25 15:30:00 |+ - - - - - - - - - - - - - - - - - - - +> > >time_df選擇(timestamp_seconds(“unix_time”)別名(“t”))printSchema()| - ts:時間戳(nullable = true)> > >火花相依設置(“spark.sql.session.timeZone”)