How to get column by number in Pandas?

前端 未结 3 1647
感动是毒
感动是毒 2020-12-05 23:10

What\'s the difference between:

Maand[\'P_Sanyo_Gesloten\']
Out[119]: 
Time
2012-08-01 00:00:11    0
2012-08-01 00:05:10    0
2012-08-01 00:10:11    0
2012-0         


        
3条回答
  •  遥遥无期
    2020-12-05 23:43

    The following is taken from http://pandas.pydata.org/pandas-docs/dev/indexing.html. There are a few more examples... you have to scroll down a little

    In [816]: df1
    
               0         2         4         6
    0   0.569605  0.875906 -2.211372  0.974466
    2  -2.006747 -0.410001 -0.078638  0.545952
    4  -1.219217 -1.226825  0.769804 -1.281247
    6  -0.727707 -0.121306 -0.097883  0.695775
    8   0.341734  0.959726 -1.110336 -0.619976
    10  0.149748 -0.732339  0.687738  0.176444
    

    Select via integer slicing

    In [817]: df1.iloc[:3]
    
              0         2         4         6
    0  0.569605  0.875906 -2.211372  0.974466
    2 -2.006747 -0.410001 -0.078638  0.545952
    4 -1.219217 -1.226825  0.769804 -1.281247
    
    In [818]: df1.iloc[1:5,2:4]
    
              4         6
    2 -0.078638  0.545952
    4  0.769804 -1.281247
    6 -0.097883  0.695775
    8 -1.110336 -0.619976
    

    Select via integer list

    In [819]: df1.iloc[[1,3,5],[1,3]]
    
               2         6
    2  -0.410001  0.545952
    6  -0.121306  0.695775
    10 -0.732339  0.176444
    

提交回复
热议问题