📜  pandas 重新排序列 - Python 代码示例

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

代码示例6
# Get column list in ['item1','item2','item3'] format 
df.columns
# [0]output: 
Index(['item1','item2','item3'], dtype='object')

# Copy just the list portion of the output and rearrange the columns 
cols = ['item3','item1','item2']

# Resave dataframe using new column order
df = df[cols]