1
给定一个DataFrame,其中索引是Datetime,如何通过只匹配日期部分来检索行?如何使用日期时间索引搜索日期时间索引
例如:
df1 =
A B C D
2011-01-13 16:00:00 344 144 616 73
2011-01-14 16:00:00 346 145 624 74
2011-01-18 16:00:00 339 146 639 77
...
并考虑:
df2['Date'] =
0 2011-01-13
1 2011-01-13
2 2011-01-26
3 2011-02-02
4 2011-02-10
5 2011-03-03
6 2011-03-03
7 2011-06-03
8 2011-05-03
9 2011-06-10
10 2011-08-01
11 2011-08-01
12 2011-12-20
我想是这样的:
for indx, row in df2.iterrows():
print df1.loc[df1.index.date() == row['Date'].date()]