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))
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))