Selecting multiple columns in a pandas dataframe

后端 未结 19 1785
醉话见心
醉话见心 2020-11-22 00:08

I have data in different columns but I don\'t know how to extract it to save it in another variable.

index  a   b   c
1      2   3   4
2      3   4   5
         


        
19条回答
  •  鱼传尺愫
    2020-11-22 00:15

    In [39]: df
    Out[39]: 
       index  a  b  c
    0      1  2  3  4
    1      2  3  4  5
    
    In [40]: df1 = df[['b', 'c']]
    
    In [41]: df1
    Out[41]: 
       b  c
    0  3  4
    1  4  5
    

提交回复
热议问题