I have a DataFrame like this:
NoDemande NoUsager Sens IdVehiculeUtilise Fait HeurePrevue HeureDebutTrajet
0 42191000823 001208 + 246Véh 1 08:20:04 08:22:26
1 42191000822 001208 + 246Véh 1 08:20:04 08:18:56
2 42191000822 001208 - 246Véh -99 09:05:03 08:56:26
3 42191000823 001208 - 246Véh 1 09:05:03 08:56:26
4 42191000834 001208 + 246Véh 1 16:50:04 16:39:26
5 42191000834 001208 - 246Véh 1 17:45:03 17:25:10
6 42192000761 001208 + 246Véh -1 08:20:04 08:15:07
7 42192000762 001208 + 246Véh 1 08:20:04 08:18:27
8 42192000762 001208 - 246Véh -99 09:05:03 08:58:29
9 42192000761 001208 - 246Véh -11 09:05:03 08:58:29
I get this data frame fromdf[df.duplicated(['NoUsager','NoDemande'],keep=False)]which ensure my rows being in pair. I want to drop a pair of rows when NoDemande are continuous numbers (like 42191000822 and 42191000823, 42192000761 and 42192000762) and the column HeurePrevue are the same, which means the records are recorded twice. I have to delete a pair and I'd like to preseve the one with more positive numbers in column Fait(at least one greater than 0)
So my result should look like:
NoDemande NoUsager Sens IdVehiculeUtilise Fait HeurePrevue HeureDebutTrajet
0 42191000823 001208 + 246Véh 1 08:20:04 08:22:26
3 42191000823 001208 - 246Véh 1 09:05:03 08:56:26
4 42191000834 001208 + 246Véh 1 16:50:04 16:39:26
5 42191000834 001208 - 246Véh 1 17:45:03 17:25:10
7 42192000762 001208 + 246Véh 1 08:20:04 08:18:27
8 42192000762 001208 - 246Véh -99 09:05:03 08:58:29
I know it's something about OR logic but I have no idea how to realize it.
Any help will be appreciated~
NoDemande, the same goes to 7 and 8. I deleted 6 and 9 because inFait, both of them are negative while only one negative between 7 and 8. 6 and 7, 8 and 9 are the same inHeurePrevue.