Delete column from pandas DataFrame

后端 未结 17 1402
一生所求
一生所求 2020-11-22 02:44

When deleting a column in a DataFrame I use:

del df[\'column_name\']

And this works great. Why can\'t I use the following?

         


        
17条回答
  •  太阳男子
    2020-11-22 03:32

    from version 0.16.1 you can do

    df.drop(['column_name'], axis = 1, inplace = True, errors = 'ignore')
    

提交回复
热议问题