How to merge two columns of a `Dataframe` in Spark into one 2-Tuple?

后端 未结 4 1977
野趣味
野趣味 2020-12-14 22:14

I have a Spark DataFrame df with five columns. I want to add another column with its values being the tuple of the first and second columns. When u

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 22:46

    If you want to merge two dataframe columns into one column. Just:

    import org.apache.spark.sql.functions.array
    df.withColumn("NewColumn", array("columnA", "columnB"))
    

提交回复
热议问题