I have data as follows:
country state area people
India Tamil Nadu urban 194
India Karnataka urban 96
Sri Lanka state1 urban 600
India Chennai urban 302
Sri Lanka state2 urban 213
India Bengaluru rural 34
Sri Lanka state3 rural 173
U.S.A NYC urban 300
Germany Scehltr rural 87
India west Bengal urban 902
Sri Lanka State 9 rural 102
And I want to group this data as here:
country state area people
India Tamil Nadu urban 194
Karnataka urban 96
Bengaluru rural 34
Chennai urban 302
Sri Lanka state1 urban 600
state2 urban 213
state3 rural 173
And I want to insert this data into a csv file in the same exact format, such that when the csv file is opened, I would get the data as in this above output.
I will be using Python Pandas for this task.