0

I have a dataframe with a column 'Country'. Every country has multiple records. I want to write a function in python using pandas so that for every country it can return a seperate dataframe.

Having a country list like , countries=['US, 'Spain', 'France'],

Individually i can do by

df_us=df[df.country=='US'] df_spain=df[df.country=='Spain'],

but how can it be done using a function! Thanks in advance

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.