How to change the order of DataFrame columns?

前端 未结 30 1599
南旧
南旧 2020-11-22 01:24

I have the following DataFrame (df):

import numpy as np
import pandas as pd

df = pd.DataFrame(np.random.rand(10, 5))
30条回答
  •  难免孤独
    2020-11-22 02:17

    How about:

    df.insert(0, 'mean', df.mean(1))
    

    http://pandas.pydata.org/pandas-docs/stable/dsintro.html#column-selection-addition-deletion

提交回复
热议问题