获得熊猫据帧值
答
print df
id product_id product_title search_term relevance
0 2 100001 Simpsom Strong anglebracket 3.00
1 3 100001 Simpsom Strong ibracket 2.50
2 16 100005 Delta Vero rainshowerhead 2.33
df = df.ix[df['id']==16, 'search_term']
print df
2 rainshowerhead
Name: search_term, dtype: object
df = df.loc[df['id']==16, 'search_term']
print df
2 rainshowerhead
Name: search_term, dtype: object
Docs - 最后一段(In [126]
)。
或者你可以使用从评论Gustavo Bezerra解决方案:
df[df['id']==16]['search_term']
^这不起作用? –
'df [df ['id'] == 16] ['search_term']' –
在您将问题扔到这里之前,请多做一点自己的研究。一些参考:http://pandas.pydata.org/pandas-docs/stable/indexing.html –