I have a dataframe df\_to\_db:

| enter\_dt\_tm | exit\_dt\_tm | total\_time | 08:00-23:00 |
| --- | --- | --- | --- |
| 2021-07-20 13:24:00 | 2021-07-20 22:51:00 | 0 days 09:27:00 | 0 days 09:27:00 |
| 2021-05-31 02:52:00 | 2021-05-31 06:16:00 | 0 days 03:24:00 | 0 days 00:00:00 |
| 2021-06-01 23:50:00 | 2021-06-01 23:58:00 | 0 days 00:08:00 | 0 days 00:00:00 |
| 2021-06-01 23:58:00 | 2021-06-02 07:58:00 | 0 days 08:00:00 | 0 days 00:00:00 |
| 2021-06-01 07:59:00 | 2021-06-01 23:12:00 | 0 days 15:13:00 | 0 days 15:00:00 |

And I want to print only the rows where there are greater than 15 minutes between "08:00-23:00" AND the "enter\_dt\_tm" timestamp is not between 07:40:00 am and 08:00:00 am (this would eliminate all but the first row).

I am writing the code as follows but am having issues:

```
test_df = df_to_db[df_to_db['08:00-23:00'] >= '0 days 00:15:00' & df_to_db['enter_dt_tm'].dt.time <= '07:40:00' & df_to_db['enter_dt_tm'].dt.time >= '08:00:00']

print(test_df)

```

The first portion where I specify 08:00-23:00 is greater than 15 minutes works, but I can't seem to figure out how to work with .dt.time to get my code to work. I have tried writing it in different formats with no luck (e.g. (7, 40, 0), 7, 40, 0) etc.

Any help would be greatly appreciated.

**EDIT: The error I am receiving is: TypeError: '<=' not supported between instances of 'datetime.time' and 'str'**