How to correct the contents of GroupedDataFrame to update it?

Hmmmm… probably an if-else statement inside the function.