【发布时间】:2021-07-09 12:45:20
【问题描述】:
我正在尝试将新记录时区添加到我的 pysaprk 数据帧
from timezonefinder import TimezoneFinder
tf = TimezoneFinder()
df = df.withColumn("longitude",col("longitude").cast("float"))
df = df.withColumn("Latitude",col("Latitude").cast("float"))
df = df.withColumn("timezone",tf.timezone_at(lng=col("longitude"), lat=col("Latitude")))
我遇到了错误。
ValueError: Cannot convert column into bool: please use '&' for 'and', '|' for 'or', '~' for 'not' when building DataFrame boolean expressions.
Timezonefinder 库用于通过传递地理坐标来查找时区。
Latitude, longitude = 20.5061, 50.358
tf.timezone_at(lng=longitude, lat=Latitude)
-- 'Asia/Riyadh'
【问题讨论】:
标签: python apache-spark pyspark user-defined-functions