Using python, how can I take the values from 2021-09-13 to 2021-09-16?
I tried the following:
date_start = df['date'].iloc[-4] #2021-09-13
date_end = df['date'].iloc[-1] #2021-09-16
df = df.loc[date_start:date_end]
but it returns only the rows for 2021-09-13 and 2021-09-16
index | date | value |
---|---|---|
2021-09-09 | 2021-09-09 | 10 |
2021-09-10 | 2021-09-10 | 20 |
2021-09-13 | 2021-09-13 | 30 |
2021-09-14 | 2021-09-14 | 40 |
2021-09-15 | 2021-09-15 | 50 |
2021-09-16 | 2021-09-16 | 60 |
Desired outcome:
index | date | value |
---|---|---|
2021-09-13 | 2021-09-13 | 30 |
2021-09-14 | 2021-09-14 | 40 |
2021-09-15 | 2021-09-15 | 50 |
2021-09-16 | 2021-09-16 | 60 |