更新时间:2023-11-18 22:52:16
要同时删除pandas中的多列,可以指定列名称,如下所示.如果希望在同一数据帧中受更改影响的列,则需要选项inplace=True
.否则将其删除.
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)