访问pandas数据帧中的数据

时间:2014-06-03 09:31:04

标签: python pandas

我有这样的数据:

                                         first          last
1CA53D87194F83E241D495A3EA5E4760  1.401797e+09  1.401797e+09
3FC2E99418049E474D71C9598E82B4A1  1.401797e+09  1.401797e+09
4776A3574944D7994785BE2E96244880  1.401797e+09  1.401797e+09
5031E7E867E809EC3F34D7666CB6CB30  1.401797e+09  1.401797e+09
647B65D306B41681B18A7AEBD16A77FC  1.401797e+09  1.401797e+09
73C3651A8E1085D10165D32A2D5A71D3  1.401797e+09  1.401797e+09
78CBE374F393DC025074CD7CF3027F26  1.401797e+09  1.401797e+09
8AED7FF3E1308EC99FBA47EA3A699862  1.401797e+09  1.401797e+09
8C57CD50FC555A4531BDB81B5E5E4802  1.401797e+09  1.401797e+09
92F85069A658E284851E2FE74499F0D1  1.401797e+09  1.401797e+09
9C368715662711FB66998B769DC2887B  1.401797e+09  1.401797e+09
A4D8875CDDBF53CBD7F9E1FDD7304622  1.401797e+09  1.401797e+09
AE233F72FE06A50707F1F23E7313BA48  1.401797e+09  1.401797e+09
B84C5781B04D1DEC2DEA8A50B122DF0F  1.401797e+09  1.401797e+09
B8C6A505573497AF4C0B46E61FD9B197  1.401787e+09  1.401797e+09
D11D5227435A934DC1590DF58F02D6D0  1.401797e+09  1.401797e+09
D4635450618911F5A3A7B6D6A08CDF6B  1.401797e+09  1.401797e+09
EB236CB26B693F2A000DFCB7F94BFF3C  1.401797e+09  1.401797e+09
EBCA0CB6BAC52C06F5D02605BDDECE92  1.401797e+09  1.401797e+09
FAF8ACF40B580D7A288BD2F7F14D6CBA  1.401797e+09  1.401797e+09

如何访问与D11D5227435A934DC1590DF58F02D6D0相关联的数据? 我希望有类似df['D11D5227435A934DC1590DF58F02D6D0']的东西。但是我说错误'No item named D11D5227435A934DC1590DF58F02D6D0

2 个答案:

答案 0 :(得分:2)

  df.ix['D11D5227435A934DC1590DF58F02D6D0']

请参阅文档:

http://pandas.pydata.org/pandas-docs/stable/indexing.html

答案 1 :(得分:1)

使用loc进行标签索引:

In [4]:

df.loc['D11D5227435A934DC1590DF58F02D6D0']
Out[4]:
first    1401797000
last     1401797000
Name: D11D5227435A934DC1590DF58F02D6D0, dtype: float64