I am trying to I am tring to delete stop words via spark,the code is as follow
from nltk.corpus import stopwords
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
sc = SparkContext('local')
spark = SparkSession(sc)
word_list=["ourselves","out","over", "own", "same" ,"shan't" ,"she", "she'd", "what", "the", "fuck", "is", "this","world","too","who","who's","whom","yours","yourself","yourselves"]
wordlist=spark.createDataFrame([word_list]).rdd
def stopwords_delete(word_list):
filtered_words=[]
print word_list
for word in word_list:
print word
if word not in stopwords.words('english'):
filtered_words.append(word)
filtered_words=wordlist.map(stopwords_delete)
print(filtered_words)
Run Code Online (Sandbox Code Playgroud)
and I got the error as follow:
pickle.PicklingError: args[0] from newobj args has the …
我有这样的数据帧:
Date PlumeO Distance
2014-08-13 13:48:00 754.447905 5.844577
2014-08-13 13:48:00 754.447905 6.888653
2014-08-13 13:48:00 754.447905 6.938860
2014-08-13 13:48:00 754.447905 6.977284
2014-08-13 13:48:00 754.447905 6.946430
2014-08-13 13:48:00 754.447905 6.345506
2014-08-13 13:48:00 754.447905 6.133567
2014-08-13 13:48:00 754.447905 5.846046
2014-08-13 16:59:00 754.447905 6.345506
2014-08-13 16:59:00 754.447905 6.694847
2014-08-13 16:59:00 754.447905 5.846046
2014-08-13 16:59:00 754.447905 6.977284
2014-08-13 16:59:00 754.447905 6.938860
2014-08-13 16:59:00 754.447905 5.844577
2014-08-13 16:59:00 754.447905 6.888653
2014-08-13 16:59:00 754.447905 6.133567
2014-08-13 16:59:00 754.447905 6.946430
Run Code Online (Sandbox Code Playgroud)
我试图保持最小距离的日期,所以删除重复日期并保持最小距离.
有没有办法在熊猫中实现这一点,df.drop_duplicates
还是我坚持使用if语句找到最小的距离?