Reputation: 5569
How can I check if at least one of the index of df2 is in df1?
df1
Val
StartDate
2015-03-31 NaN
2015-04-03 NaN
2015-04-05 8.08
2015-04-06 23.48
df2
Val
StartDate
2015-03-31 True
2015-04-01 True
2015-04-02 True
2015-04-03 True
2015-04-04 True
2015-04-05 True
2015-04-06 True
df2.index in df1.index
returns False
Upvotes: 0
Views: 1488
Reputation: 863256
Use Index.isin
with Index.any
for check at least one True
:
a = df1.index.isin(df2.index).any()
print (a)
True
Detail:
print (df1.index.isin(df2.index))
[ True True True True]
Upvotes: 1