basically you have to create a dataframe (or use a window function, that will also work) which gives you the group combination with the most occurances. So a window/groupby on object, name, shape with a count().
Then you have to determine which shape has the max(count) for a object/name combo.
can also be done using groupby or window.
Finally you filter on this max et voila.
If you use window functions you can avoid a join I think (doin this out of my head).