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!

4
  • I'm using Python and Pandas' module. Commented Feb 28, 2021 at 15:01
  • did you try this ? Commented Feb 28, 2021 at 15:02
  • df.loc['2020-01-13':'2020-02-14'] Commented Feb 28, 2021 at 15:03
  • Thanks for the quick help, it works as expected now! Commented Feb 28, 2021 at 15:08

1 Answer 1

2

You can filter the index using loc:

df.loc[(df.index >= '2020-01-13') & (df.index <= '2020-02-14')]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.