Quantcast
Viewing all articles
Browse latest Browse all 4448

Checking if every Present record between next records in python

@jnpraveenreddy wrote:

I have data which is imported from MySQLdb to Python.

I want to check present every logout_time is falling in between next record of login_time and logout_time if yes I need to print the first record of login_time and last breaking record of logout_time else the same records.

id | login_time           | logout_time
1  |'2017-12-07 11:20:00' | '2017-12-07 11:50:00'
2  |'2017-12-07 12:51:00' | '2017-12-07 13:30:00'
3  |'2017-12-07 13:20:00' | '2017-12-07 16:50:00'
4  |'2017-12-07 16:51:00' | '2017-12-07 17:10:00'
5  |'2017-12-07 17:00:00' | '2017-12-07 18:00:00'
6  |'2017-12-07 17:50:00' | '2017-12-07 19:00:00'

the final output is:

 login_time           | logout_time
'2017-12-07 11:20:00' | '2017-12-07 11:50:00'
'2017-12-07 12:51:00' | '2017-12-07 16:50:00'
'2017-12-07 16:51:00' | '2017-12-07 19:00:00'

Help me please.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4448

Trending Articles