I want to merge rows of data frame based on similar timestamp.
import pandas as pd
df = pd.DataFrame([VEST,False,0.6993550658226013,2019-11-27 18:56:12.616425+05:30],
[HELMET,True,0.8506404161453247 ,2019-11-27 18:56:12.616425+05:30],
[HELMET,True,0.5948962569236755 ,2019-11-27 18:56:13.617801+05:30],
[VEST,False,0.6576083898544312 ,2019-11-27 18:56:14.595118+05:30],
[HELMET,True,0.8451269865036011 ,2019-11-27 18:56:14.595118+05:30],
[VEST,True,0.7157155275344849 ,2019-11-27 18:56:15.625841+05:30],
[HELMET,True,0.80693519115448 ,2019-11-27 18:56:15.625841+05:30],
[HELMET,True,0.5428823232650757 ,2019-11-27 18:56:41.639505+05:30],
[VEST,False,0.6302998661994934 ,2019-11-27 18:56:42.582407+05:30],
[HELMET,True,0.8790003657341003 ,2019-11-27 18:56:42.582407+05:30],
[VEST,False,0.44062405824661255 ,2019-11-27 18:56:44.590130+05:30],
[HELMET,True,0.9355553388595581, 2019-11-27 18:56:44.590130+05:30 ],columns = ['Type', 'voilation', 'score', 'timestamp'])
Is there any way to merge rows with similar type and timestamp (2-3 secs) and assign violation type based on highest score.
df.groupby(['Type', 'timestamp'])
Groupby generates only 3 frames. Not able to figure quite what to do. Any help is appreciated.