简体   繁体   English

仅在选定的列上使用 NVL 逻辑 spark dataframe scala

[英]Use NVL logic only on selected columns spark dataframe scala

I need to replace only null values in selected columns in a dataframe.我只需要替换数据框中选定列中的空值。 I know we have df.na.fill option .我知道我们有df.na.fill选项。 How can we implement it only on selected columns or is there any better option other than using df.na.fill我们如何仅在选定的列上实现它,或者除了使用df.na.fill之外还有什么更好的选择

Reading spark documentation here we can see that fill is well suited for your need. 在此处阅读 spark 文档我们可以看到 fill 非常适合您的需要。 You can do something like:您可以执行以下操作:

df.na.fill(0, Seq("colA", "colB"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM