gpt4 book ai didi

pyspark sql : AttributeError: 'NoneType' object has no attribute 'join'

转载 作者:行者123 更新时间:2023-12-03 22:09:34 24 4
gpt4 key购买 nike

def main(inputs, output):

sdf = spark.read.csv(inputs, schema=observation_schema)
sdf.registerTempTable('filtertable')

result = spark.sql("""
SELECT * FROM filtertable WHERE qflag IS NULL
""").show()

temp_max = spark.sql(""" SELECT date, station, value FROM filtertable WHERE (observation = 'TMAX')""").show()
temp_min = spark.sql(""" SELECT date, station, value FROM filtertable WHERE (observation = 'TMIN')""").show()

result = temp_max.join(temp_min, condition1).select(temp_max('date'), temp_max('station'), ((temp_max('TMAX')-temp_min('TMIN'))/10)).alias('Range'))

错误:

Traceback (most recent call last):
File "/Users/syedikram/Documents/temp_range_sql.py", line 96, in <module>
main(inputs, output)
File "/Users/syedikram/Documents/temp_range_sql.py", line 52, in main
result = temp_max.join(temp_min, condition1).select(temp_max('date'), temp_max('station'), ((temp_max('TMAX')-temp_min('TMIN')/10)).alias('Range'))
AttributeError: 'NoneType' object has no attribute 'join'

执行连接操作给了我 Nonetype 对象错误。在线查看没有帮助,因为 pyspark sql 的在线文档很少。
我在这里做错了什么?

最佳答案

删除 .show()来自 temp_maxtemp_min因为 show 只打印一个字符串,不返回任何内容(因此你得到 AttributeError: 'NoneType' object has no attribute 'join' )。

关于pyspark sql : AttributeError: 'NoneType' object has no attribute 'join' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52753083/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com