如何在数据框中附加列值

时间:2018-07-27 11:36:35

标签: scala apache-spark databricks

enter image description here我有一个包含两列的数据框(文本,有用)。我想将大于20的“有用”列中的任何值替换为1,否则设置为零。需要一些帮助。我在databricks社区中使用Scala

+--------------------+------+
|Located in a base...|     0|
| I am not a vegeta  |    12|



+--------------------+------+
|                text|useful|
+--------------------+------+
|Located in a base...|     0|
|I am not a vegeta...|     1|
|There is so many ...|    12|
|Disclaimer: this ...|     0|
|House Special Chi...|     0|
|The food at Chez ...|     2|
|Overall not bad. ...|     3|

enter image description here

df

0 个答案:

没有答案