[英]How to update all the columns of a dataframe in java
In scala we can update all the columns of a dataframe with the help of below 在Scala中,我们可以借助以下帮助更新数据框的所有列
val outputDF = InputDF.select(InputDF.columns.map(c => toLower(col(c))):_*)
How to handle the above scenario in Java in an immutable way ? 如何以不变的方式处理Java中的上述情况?
It would be pretty the same: 差不多一样:
inputDF.select(Arrays.stream(inputDF.columns()).map(c ->lower(col(c))).toArray(Column[]::new));
You can also do it with a loop: 您还可以循环执行此操作:
Dataset outputDF = inputDF;
for (String c : inputDF.columns()){
outputDF = outputDF.withColumn(c, lower(col(c)));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.