我有这样一个数据框:
Col1 Col2 Col3 Col4 Col5 Col6
1 1982 0 0 -211 107 0
2 4412 0 989 0 296 0
3 0 -5051 0 -267 389 920
4 0 -2983 0 -215 0 1639
5 0 -1326 0 -861 0 0
6 3722 0 89 0 243 13349
字符串
如何将负值更改为零值?使用Scala和spark
预期结果
Col1 Col2 Col3 Col4 Col5 Col6
1 1982 0 0 0 107 0
2 4412 0 989 0 296 0
3 0 0 0 0 389 920
4 0 0 0 0 0 1639
5 0 0 0 0 0 0
6 3722 0 89 0 243 13349
型
1条答案
按热度按时间mbskvtky1#
在这种情况下,尝试使用
Case when
语句,检查值是否为< 0
,否则为0,保持值不变。Example:
字符串