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

Time:04-12

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

CodePudding user response:

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"]
  • Related