Dropping Multiple Columns from a data frame using Python

前端 未结 1 1086
别那么骄傲
别那么骄傲 2021-01-04 23:15

I know how to drop columns from a data frame using Python. But for my problem the data set is vast, the columns I want to drop are grouped together or are basically singular

相关标签:
1条回答
  • 2021-01-04 23:49

    To delete multiple columns at the same time in pandas, you could specify the column names as shown below. The option inplace=True is needed if one wants the change affected column in the same dataframe. Otherwise remove it.

    flight_data_copy.drop(['TailNum', 'OriginStateFips', 
                    'DestStateFips', 'Diverted'], axis=1, inplace=True)
    

    Source: Python Pandas - Deleting multiple series from a data frame in one command

    0 讨论(0)
提交回复
热议问题