我有df
:
Id Timestamp Data Id Day
2012-04-21 19389576 2012-04-21 00:04:03.533 39.0 1 2012-04-21
2012-04-21 19389577 2012-04-21 00:04:04.870 38.5 1 2012-04-21
2012-04-21 19389608 2012-04-21 00:07:03.450 38.0 1 2012-04-21
2012-04-22 19389609 2012-04-21 00:03:04.817 37.5 2 2012-04-21
2012-04-22 19389620 2012-04-21 00:10:04.400 37.0 2 2012-04-21
...
日期的第一列是索引。如何获得相应的Id
值,其中index == 2012-04-21
和Data ==39
,即1
?我尝试了iloc
和loc
,但不确定如何处理索引。谢谢。
答案 0 :(得分:1)
让我们尝试
df.loc[(df.index=='2012-04-21') & (df.Data==39) ,'Id']