Reputation: 972
How can one get the list of dates in a datetimeindex that are less or equal to a given date?
What kind of slicing to do?
I have tried to [ index < date ] without success,
Upvotes: 1
Views: 407
Reputation: 68146
If it's a series and the index is sorted (it should be) just do:
mySeries[:myDateString]
This is very clearly demnostrated in the documentation: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#datetimeindex-partial-string-indexing
If the index isn't sorted, just use logical indexing:
mySeries[mySeries.index < myTimeStamp]
Upvotes: 2