How do I remove a column from a DataFrame in Python?

Thu Ha

New member
How do I remove a column from a DataFrame in Python?
Answer
To delete rows and columns from DataFrames,
Pandas uses the “drop” function
. To delete a column, or multiple columns, use the name of the column(s), and specify the “axis” as 1. Alternatively, as in the example below, the ‘columns’ parameter has been added in Pandas which cuts out the need for ‘axis’.
 

Tìm kiếm

Back
Top