Reputation: 816
If I have a pandas data frame like this with a time index:
2018-01-19 01:32:00.000
2018-01-19 01:32:00.500
2018-01-19 01:32:01.000
2018-01-19 01:32:01.500
2018-01-19 01:32:02.000
2018-01-19 01:32:02.500
2018-01-19 01:32:03.000
2018-01-19 01:32:03.500
And an array of time stamps like this:
np.array(['2018-01-19 01:32:00.000', '2018-01-19 01:32:01.500', '2018-01-19 01:32:03:00'])
How do I return the index values that match my array of time stamps? Such that I return an array that looks like this:
np.array(0, 3, 6)
Upvotes: 0
Views: 41
Reputation: 323396
You can check with get_indexer
df.index.get_indexer(a)
array([ 0, 3, 6])
Upvotes: 1