本文翻译自:Delete column from pandas DataFrame
When deleting a column in a DataFrame I use: 在删除DataFrame中的列时,我使用:
del df['column_name']
And this works great. 这很棒。 Why can't I use the following? 为什么不能使用以下内容?
del df.column_name
As you can access the column/Series as df.column_name
, I expect this to work. 因为您可以使用df.column_name
来访问列/系列, df.column_name
我希望这可以正常工作。
#1楼
参考:https://stackoom.com/question/uGxE/从pandas-DataFrame删除列
#2楼
It's good practice to always use the []
nota