Using DatetimeIndex function:
To select DataFrame value between two dates, you can simply use pandas.date_range function.
For example:
import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.random((200,3)))
df['date'] = pd.date_range('2000-1-1', periods=200, freq='D')
df = df.set_index(['date'])
print(df.loc['2000-6-1':'2000-6-10'])
yields
Output:
date 0 1 2
2000-06-01 0.040457 0.326594 0.492136
2000-06-02 0.279323 0.877446 0.464523
2000-06-03 0.328068 0.837669 0.608559
2000-06-04 0.107959 0.678297 0.517435
2000-06-05 0.131555 0.418380 0.025725
2000-06-06 0.999961 0.619517 0.206108
2000-06-07 0.129270 0.024533 0.154769
2000-06-08 0.441010 0.741781 0.470402
2000-06-09 0.682101 0.375660 0.009916
2000-06-10 0.754488 0.352293 0.339337
Python’s list indexing, e.g. seq[start : end] includes start but not end index, Pandas df.loc[start_date:end_date] includes both end-points in the result if they are in the index.
Hope this answer helps.