How to change a column position in a spark dataframe?

后端 未结 6 1039
无人共我
无人共我 2020-12-08 19:33

I was wondering if it is possible to change the position of a column in a dataframe, actually to change the schema?

Precisely if I have got a dataframe like [f

6条回答
  •  粉色の甜心
    2020-12-08 19:40

    for any dynamic frame, firstly convert dynamic frame to data frame to use standard pyspark functions

    data_frame = dynamic_frame.toDF()
    

    Now, rearrange columns to new data frame using select function operation.

    data_frame_temp = data_frame.select(["col_5","col_1","col_2","col_3","col_4"])
    

提交回复
热议问题