[尝试使用简单的代码行使用熊猫作为phyton从数据框中删除列。
我要删除的列的名称是“注释”
traveltime_df = travelTime_df.drop('Comments',1)
它没有给出任何错误;但随后我打印了数据框,并看到“注释”列仍然存在
这里有2种可能的方式:-
第一种方式:-
travelTime_df.drop(['Comments'], axis=1)
第二种方式:-
travelTime_df.drop(columns=['Comments'])
[添加深潜链接:-https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html