how to slice dataframe based on daterange in pandas

In [15]: df = pd.DataFrame([1, 2, 3], index=[dt.datetime(2013, 1, 1), dt.datetime(2013, 1, 3), dt.datetime(2013, 1, 5)])

In [16]: df
Out[16]: 
            0
2013-01-01  1
2013-01-03  2
2013-01-05  3

In [22]: start = df.index.searchsorted(dt.datetime(2013, 1, 2))

In [23]: end = df.index.searchsorted(dt.datetime(2013, 1, 4))

In [24]: df.iloc[start:end]
Out[24]: 
            0
2013-01-03  2

Here is what the above code is Doing:
1. Create a DataFrame with three rows, each with a single column. The index is a list of datetimes.
2. Find the index of the datetime 2013-01-02.
3. Find the index of the datetime 2013-01-04.
4. Use the .iloc indexer to select the rows with indices start and end.

Note that the .iloc indexer is inclusive of the start and exclusive of the end.

The .searchsorted() method is a convenience for finding indices of a sorted array.