我在尝试打印基于index values
>>>in: print(df) # My table when I print df
>>>out:
Item Column1 Column2 Column3 Column4 Column5
Fooooo 64.318 7.574 0.471 0.364 -
Yooooo 56.839 7.252 (1.914) (1.945) (0.015)
Zaaaaa 45.275 7.186 (7.109) (1.611) (0.016)
Zorrrr 0.381 0.063 (5.305) (1.6) (0.017)
Kaarrr 1.325 0.26 (5.514) (2.563) (0.019)
期望的结果
如何通过df
分隔index
,以便产生以下结果?
>>>in: print(df index['Fooooo']) # For example
>>>out:
Item Column1 Column2 Column3 Column4 Column5
Fooooo 64.318 7.574 0.471 0.364 -
>>>in: print(df index['Yooooo']) # For example
>>>out:
Item Column1 Column2 Column3 Column4 Column5
Yooooo 56.839 7.252 (1.914) (1.945) (0.015)
>>>in: print(df index['Zaaaaa']) # For example
>>>out:
Item Column1 Column2 Column3 Column4 Column5
Zaaaaa 45.275 7.186 (7.109) (1.611) (0.016)
我试过
print(df.index[0])
- 这只是给了我Item
。不与Columns
答案 0 :(得分:2)
您可以使用ix:
In[31]:df.ix['Fooooo']
Out[31]:
Column1 64.318
Column2 7.574
Column3 0.471
Column4 0.364
Column5 -
答案 1 :(得分:1)
尝试过滤方法:
df[df.index == 'Fooooo']
Column1 Column2 Column3 Column4 Column5
Item
Fooooo 64.318 7.574 0.471 0.364 -