Python/pyspark data frame rearrange columns Python/pyspark data frame rearrange columns python python

Python/pyspark data frame rearrange columns


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

df.select("id","name","time","city")


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

df.select(sorted(df.columns))