0

I want to create new data frame that select rows that has range date from df['Date'] column between 2020-01-01 to 2020-03-31 in pandas python from below data frame. Anyone can help me?

  Date        Name      Status
0 2020-01-01  Ali       Closed
1 2020-01-05  Sara      Closed
2 2020-02-15  Tyra      Approve
3 2020-03-19  Alia      Reject
4 2020-03-29  Aiman     Closed
5 2020-05-01  Alice     Closed
6 2020-07-12  Danish    Closed
Ch3steR
  • 20,090
  • 4
  • 28
  • 58
  • Does this answer your question? [Select DataFrame rows between two dates](https://stackoverflow.com/questions/29370057/select-dataframe-rows-between-two-dates) – Joe Jun 17 '20 at 05:19

1 Answers1

0

You can use boolean indexing to select rows based on a condition.

mask = (df['Date'] >= '2020-01-01') & (df['Date'] <= '2020-03-31')
q1_df = df[mask]
Miki Tebeka
  • 13,428
  • 4
  • 37
  • 49
  • You got twice as much rep as me, how about taking 5 seconds to check for a duplicate? :) – Joe Jun 17 '20 at 05:21