Python/pyspark data frame rearrange columns

前端 未结 2 1947
囚心锁ツ
囚心锁ツ 2020-12-05 10:10

I have a data frame in python/pyspark with columns id time city zip and so on......

Now I added a new column

相关标签:
2条回答
  • 2020-12-05 10:31

    If you're working with a large number of columns:

    df.select(sorted(df.columns))
    
    0 讨论(0)
  • 2020-12-05 10:34

    You can use select to change the order of the columns:

    df.select("id","name","time","city")
    
    0 讨论(0)
提交回复
热议问题