【发布时间】:2023-04-07 04:02:01
【问题描述】:
我在本地处理 pyspark 1.4 中的数据帧,并且在使 dropDuplicates 方法工作时遇到问题。它不断返回错误:
"AttributeError: 'list' 对象没有属性 'dropDuplicates'"
不太清楚为什么,因为我似乎遵循latest documentation 中的语法。
#loading the CSV file into an RDD in order to start working with the data
rdd1 = sc.textFile("C:\myfilename.csv").map(lambda line: (line.split(",")[0], line.split(",")[1], line.split(",")[2], line.split(",")[3])).collect()
#loading the RDD object into a dataframe and assigning column names
df1 = sqlContext.createDataFrame(rdd1, ['column1', 'column2', 'column3', 'column4']).collect()
#dropping duplicates from the dataframe
df1.dropDuplicates().show()
【问题讨论】:
标签: python apache-spark pyspark duplicates pyspark-dataframes