TypeError:'DataFrame'对象不可调用-Spark数据框

时间:2019-03-19 11:30:58

标签: python apache-spark dataframe pyspark typeerror

我在执行提到的“ join”语句时遇到错误。我正在使用pyspark安装程序。连接语句或代码中所需的任何更改。

TypeError:“ DataFrame”对象不可调用

df11 = spark.read.option("header","true").option("delimiter", ",").csv("s3://mybucket/file1.csv")
df22 = spark.read.option("header","true").option("delimiter", ",").csv("s3://mybucket/file2.csv")
df11.createOrReplaceTempView("table1")
df22.createOrReplaceTempView("table2")
df1 = spark.sql( "select * from table1" )
df2 = spark.sql( "select * from table2" )

df_d = df1.join(df2, df1.NO == df2.NO, 'left').filter(F.isnull(df2.NO)).select(df1.NO,df1.NAME,df1.LAT,df1.LONG, F.lit('DELETE').alias('FLAG'))

谢谢

1 个答案:

答案 0 :(得分:3)

使用col名称作为这样的字符串,它应该可以工作

df_d = df1.join(df2, df1['NO'] == df2['NO'], 'left').filter(F.isnull(df2['NO'])).select(df1['NO'],df1['NAME'],df1['LAT'],df1['LONG'], F.lit('DELETE').alias('FLAG'))