简体   繁体   English

如何在Java中更新数据框的所有列

[英]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.

相关问题 如何使用 java 连接火花 dataframe 中的所有列? - how to concat all columns in a spark dataframe, using java? 如何对Java中的列组合对火花数据框进行排序? - How to sort spark dataframe on the combination of columns in Java? 如何通过单击 jbutton 更新所有空列的值,而在 java 中保持表中的其他数据不变? - How to update the value of all empty columns with the click of a jbutton, leaving the other data in a table unchanged in java? 如何在Java中打印pearson Matrix的所有列 - How to print all the columns of the pearson Matrix in Java 当DataFrame有列时如何使用Java Apache Spark MLlib? - How to work with Java Apache Spark MLlib when DataFrame has columns? Java:如何根据对象列表向 dataframe 添加列 - Java : how to add columns to dataframe based on a list of objects 如何在 Spark Java 中使用数据框构建基于其他列的列? - How to construct a column based on other columns using dataframe in Spark Java? 如何使用 Java 在 Spark SQL 中加入多列以在 DataFrame 中进行过滤 - How to Join Multiple Columns in Spark SQL using Java for filtering in DataFrame 在火花 java dataframe 中合并列 - Coalesce columns in spark java dataframe 如何搜索所有列并更新特定值SQLite - How can I search all Columns and Update specific value SQLite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM