Reputation: 37
In a given data frame mydf
, I removed a column from the data frame through:
mydf.drop('Z', axis=1)
However, in the following parts, the removed column Z
is still there, e.g., when I write print(mydf.sum())
after the previous cell, it gives me the sum of column Z
with the sum of other columns. How can I delete the column Z
permanently?
Upvotes: 1
Views: 1799
Reputation: 14191
You have to assign it back to mydf
, if you want to reach a permanent change, i.e. do
mydf = mydf.drop('Z', axis=1)
instead.
Upvotes: 4