All, I have dataframe of bounding boxes in an image with each box being in a separate row. What I want to do is combine all the rows for a specific image.
image xmin ymin xmax ymax label
0 bookstore_video0_40.jpg 763 899 806 940 pedestrian
3 bookstore_video0_40.jpg 1026 754 1075 797 pedestrian
4 bookstore_video0_40.jpg 868 770 927 822 biker
5 bookstore_video0_40.jpg 413 1010 433 1040 pedestrian
21 bookstore_video0_80.jpg 866 278 917 328 pedestrian
22 bookstore_video0_80.jpg 761 825 820 865 biker
What I am thinking is maybe make this into a single level nested dictionary, note I am open to any solution and I am not fixed to a dictionary, like this maybe.
{'bookstore_video0_40.jpg': {'xmin': 1066, 'ymin': 802, 'xmax': 1093, 'ymax': 829, 'label': 'pedestrian'}
But with all rows data with the image name as the key. My end goal is to then pass this to a function that will sequentially write each row's data into a file. That all being said I am lost on how to group the data into blocks. I did groupby(‘image’) but I could not figure out how to then turn that data into something like what I want. Does anyone have ideas? I am pretty sure this is easy and I have looked around but most of the responses I have seen were for much more complicated questions. Thanks in advance.