Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to drop a column from Dictionary, which is assigned to be the key and required to drop it

df_countries = dict(list(df_countries.groupby('Country'))) 
for df in df_countries.values():     
    df.drop('Country', axis=1)

df_countries["Australia"]

Above is the coding that I typed, but how to drop the column country?? From the output, the column ‘Country’ didn’t drop

Output 1Output 2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try adding the inplace=True parameter

df_countries = dict(list(df_countries.groupby('Country'))) 
for df in df_countries.values():     
    df.drop('Country', inplace=True, axis=1)

df_countries["Australia"]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading