0

I have a dataframe with 1000 records. I am trying to filter only the below Dates record from the df

2020-06-09

2020-08-06

2020-08-25

I have tried the below code hoping that my code will filter only those records available for that particular date.

df[(df['Date'] == '2020-06-09') & (df['Date'] = '2020-08-06') & (df['Date'] = '2020-08-25')]

But i am not getting any output. I need to view the dataframe only for those particular dates.

1
  • 1
    You need to replace the & with | operator Commented Aug 28, 2020 at 14:09

1 Answer 1

1

You can use isin:

df = df[df['date'].isin(['2020-06-09', '2020-08-06', '2020-08-25'])]

Method 2

dates = ['2020-06-09', '2020-08-06', '2020-08-25']
df = df.query("date in @dates")
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.