Examples

In [1]:
import numpy as np
import pandas as pd
In [2]:
i = pd.date_range('2019-02-09', periods=4, freq='2D')
ts = pd.DataFrame({'X': [1,2,3,4]}, index=i)
ts
Out[2]:
X
2019-02-09 1
2019-02-11 2
2019-02-13 3
2019-02-15 4

Get the rows for the last 3 days:

In [3]:
ts.last('3D')
Out[3]:
X
2019-02-13 3
2019-02-15 4

Note: The data for 3 last calender days were returned, not the last 3 observed days in the dataset,
and therefore data for 2019-02-11 was not returned.