如何提高对Pandas数据框的列表理解速度
除了列表理解之外,是否有更快的方法从集合中过滤项目,对于大型数据集,列表理解运行时间有点慢。
我已经将 the 转换list_stopwords为一个集合,与列表相比,它花费的时间更少。
date description
0 2018-07-18 payment receipt
1 2018-07-18 ogsg s.u.b.e.b june 2018 salar
2 2018-07-18 sal admin charge
3 2018-07-19 sms alert charge outstanding
4 2018-07-19 vat onverve*issuance
list_stopwords = set(stop_words.get_stop_words('en'))
data['description'] = data['description'].apply(lambda x: " ".join([word for word in x.split() if word not in (list_stopwords)]))