I have this dataframe
df = pd.DataFrame({
    'text': ['a', 'a', 'a', 'b', 'b'],
    'group': [1, 1, 1, 2, 2],
    'value': [1, 2, 3, 4, 5],
    'some_other_to_include': ['a', 'a', 'c', 'b', 'b'],
    'criticality': [3, 3, 5, 4, 4]
})
Where i want to group by the 'group' column, then take an average of the value column while selecting the row with the highest 'criticality' and keeping the other columns
Intended result:
text    group    value    some_other_to_include    criticality
a       1        2        c                        5
b       2        4.5      b                        4
But i can't figure out a way without building a new dataframe from scratch and using nlargest and avg. Is there a smarter way of doing this?
 
    