2016-08-11 12 views

回答

1

您可以通過stack實現這個荷蘭國際集團的框架產生一系列所有的值,那麼,我們想用to_frame然後reset_index下降的指數水平,然後轉用.T轉換這回DF:

In [2]: 
df = pd.DataFrame(np.random.randn(4,3), columns=list('abc')) 
df 

Out[2]: 
      a   b   c 
0 -1.744219 -2.475923 1.794151 
1 0.952148 -0.783606 0.784224 
2 0.386506 -0.242355 -0.799157 
3 -0.547648 -0.139976 -0.717316 

In [3]: 
df.stack().to_frame().reset_index(drop=True).T 

Out[3]: 
     0   1   2   3   4   5   6 \ 
0 -1.744219 -2.475923 1.794151 0.952148 -0.783606 0.784224 0.386506 

     7   8   9   10  11 
0 -0.242355 -0.799157 -0.547648 -0.139976 -0.717316 
相關問題