メインコンテンツまでスキップ

from_unixtime

Unix エポック (1970-01-01 00:00:00 UTC) の秒数を、指定された形式で現在のシステム タイム ゾーンのその瞬間のタイムスタンプを表す文字列に変換します。

対応する Databricks SQL 関数については、 from_unixtime関数を参照してください。

構文

Python
from pyspark.databricks.sql import functions as dbf

dbf.from_unixtime(timestamp=<timestamp>, format=<format>)

パラメーター

パラメーター

Type

説明

timestamp

pyspark.sql.Column または str

UNIX 時間値の列。

format

literal string, optional

変換に使用する形式(デフォルト:yyyy-MM-dd HH:mm

戻り値

pyspark.sql.Column: タイムスタンプを文字列としてフォーマットします。

Python
spark.conf.set("spark.sql.session.timeZone", "America/Los_Angeles")
Python
from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([(1428476400,)], ['unix_time'])
df.select('*', dbf.from_unixtime('unix_time')).show()
spark.conf.unset("spark.sql.session.timeZone")