【发布时间】:2021-02-03 09:43:33
【问题描述】:
我想从每一行的另一个数据框中减去或删除一个数据框中的单词。
这是 pyspark 数据框的主表/列。
+----------+--------------------+
| event_dt| cust_text|
+----------+--------------------+
|2020-09-02|hi fine i want to go|
|2020-09-02|i need a line hold |
|2020-09-02|i have the 60 packs|
|2020-09-02|hello want you teach|
下面是另一个 pyspark 数据框。此数据框中的单词需要从上述主表中的列cust_text 中删除,无论单词出现在每一行中。例如,'want' 将从每行中删除,只要它出现在第一个数据帧中。
+-------+
|column1|
+-------+
| want|
|because|
| need|
| hello|
| a|
| have|
| go|
+-------+
这可以在 pyspark 或 pandas 中完成。我尝试使用 Python、Pyspark、pandas 搜索解决方案,但仍然无法根据单列表从主表中删除单词。
结果应该是这样的:
+----------+--------------------+
| event_dt| cust_text|
+----------+--------------------+
|2020-09-02|hi fine i to |
|2020-09-02|i line hold |
|2020-09-02|i the 60 packs |
|2020-09-02|you teach |
+----------+--------------------+
【问题讨论】:
标签: python pandas dataframe text pyspark