0

I'm trying to remove some columns from my dataframe, however I'm just getting this error no matter how hard I try to figure out how to fix it. Could you help me?

drop_cols = ['ISO3A código economía declarante',
 'ISO3A código economía asociada',
 'Código metadatos del valor',
 'Metadatos del valor',
 'Valor (no numérico)']

data = data.drop([drop_cols], axis=1)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-58-0d59600c7b98> in <module>
----> 1 data = data.drop([drop_cols], axis=1)

AttributeError: 'NoneType' object has no attribute 'drop'

I also used inplace = True and it didn't work for me either

1 Answers1

0
new_df=df.drop(['drop_cols'],axis=columns,inplace=True)
Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 24 '22 at 13:21
  • Besides, this answer doesn't work. It is contradictory to specify `inplace=True` and to expect a new dataframe to be returned. – chrslg Nov 01 '22 at 20:47