2022-12-23

Converting list of string into dataframe row

I have the following continent to country

pd.DataFrame({'asia':[['china','india','australia']],
              'europe':[['spain','uk','russia','france','germany']],
              'americas':[['canada','usa','mexico']]
            }).transpose()

How do I convert into

asia | china
asia | india
asia | australia
europe | spain
europe | uk

etc. .



No comments:

Post a Comment