I have a PostgreSQL query in Python with data of reservations. These reservations have a date.
I would like to make a filter where the user says which interval of dates are going to be in the dataframe.
For example, I would like to have the reservations from 01-01-22 to 01-03-22.
The problem is that I don't know how to create this filter, and whether it should be in Python or in my SQL query!
My DF looks basically like this:
| Date | Reservation ID | Route |
|---|---|---|
| 01-01-22 | 35642 | LA-SD |
| 01-02-22 | 12432 | LA-SD |
| 01-03-22 | 55652 | LA-SD |
| 01-04-22 | 87642 | LA-SD |
| 01-05-22 | 97612 | LA-SD |
| 01-06-22 | 09731 | LA-SD |
| 01-06-22 | 25876 | LA-SD |
| 01-08-22 | 23775 | LA-SD |
DataFrame.query?select '01/03/2022'::date <@ daterange('01-01-2022', '01-03-2022', '[]'); twhere range operators are explained here Range operators.