0

I have got a dataframe like:

*nothing*            open          high
2020-01-12            122            59
2020-01-13            113            52
2020-02-14            144            64
2020-03-15            135            64

How can I only select rows from 2020-01-13 to 2020-02-14 using a filter? I'm aware there are more questions like these but this dataframe doesn't have a name for the date column (e.g. the date is the index).

Thank you!

Eric
  • 55
  • 5

1 Answers1

2

You can filter the index using loc:

df.loc[(df.index >= '2020-01-13') & (df.index <= '2020-02-14')]
mck
  • 40,932
  • 13
  • 35
  • 50