Have a dataframe which has user, location, values. Currently US related location are in different rows for one user:
user location values
209 OH_US 45
O09 PA_US 30
O09 AQ 10
209 CA_US 50
209 UK 10
....
For each user want to generate a new row to replace US related locations with a sum and location name is 'US'.Remove those rows in different states in US. Expected result looks like this:
user location values
209 US 200
209 UK 10
O09 US 300
O09 AQ 10
...
Currently I'm thinking to pull all US related rows to a separate dataframe to do a sum in groupby, then drop all the rows related to US in original dataframe to join with the US sum dataframe.
Is there a more efficient way to do this?