Building a StructType from a dataframe in pyspark

后端 未结 4 1032
后悔当初
后悔当初 2021-02-04 06:45

I am new spark and python and facing this difficulty of building a schema from a metadata file that can be applied to my data file. Scenario: Metadata File for the Data file(csv

4条回答
  •  长发绾君心
    2021-02-04 07:26

    val columns: Array[String] = df1.columns
    val reorderedColumnNames: Array[String] = df2.columns //or do the reordering you want
    val result: DataFrame = dataFrame.select(reorderedColumnNames.head, reorderedColumnNames.tail: _*)
    

提交回复
热议问题