📜  更改列顺序 pandas - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:40.290000             🧑  作者: Mango

代码示例5
# Want to change column3 to show up first
df = pd.Dataframe({
  "column1":(1,2,3),
  "column2":(4,5,6),
  "column3":(7,8,9)
}
# From all solutions I could find, this seems to be the best performance wise:
col = df.pop(col_name)
df.insert(0, col.name, col)# <- works in place and returns None (at least for me)