0

嗨,我目前正在通过 Spark 处理时间序列数据并处理时区。

SparkSQL 的一些内置函数使用了特定的时区参数,例如:

pyspark.sql.functions.from_utc_timestamp(timestamp, tz)

Assumes given timestamp is UTC and converts to given timezone.

>>> df = sqlContext.createDataFrame([('1997-02-28 10:30:00',)], ['t'])
>>> df.select(from_utc_timestamp(df.t, "PST").alias('t')).collect()
[Row(t=datetime.datetime(1997, 2, 28, 2, 30))]
New in version 1.5.

在我的情况下,使用时区简写可能不方便,因为时区信息以“+01:00”的格式存储。

所以我的问题是:如何将“+01:00”格式的偏移字符串合并到火花数据帧中,以便考虑偏移?

4

1 回答 1

0

您可以按照java.util.TimeZone 文档中的说明 使用GMT+01:00

于 2017-04-27T11:17:01.863 回答