I'm facing a challenge when I'm trying to group a dataframe, here's a fake datafram which similir to the real one :
**univertcity country sector name firstname code**
Evergreen College USA URO Isabel Emily 694123
Evergreen College USA URO Rami David 63123
Evergreen College Swiss URO Johnson Parker 114196
Cascade University CANADA DIG Anthony Jessica 55177
Cascade University CANADA VIP Michael Thierry 124199
Horizon Institute FRANCE MP Ben Samuel 25896
Horizon Institute FRANCE MP Benjamin John 52366
what I'm looking for is to group by univercity col the country and finaly the sector, and I would like (somehow) to fetch each grouping sepratly..because i woulf like to display each grouping using html table..the is what i intend to get :
could you help please ?
Just use groupby:
gp = df.groupby(["univertcity", "country", "sector"])
for key, item in gp:
print(gp.get_group(key), "\n\n")