CBSE Class 12 Informatics Practices Question 108 of 167

Python Pandas — I — Question 19

Back to all questions
19
Question

Question 19

How would you delete columns from a dataframe ?

Answer

To delete columns from a dataframe, we use the del statement with the syntax:

del <Df object>[<column name>]

OR

df.drop([<column name], axis = 1).

For example, the statement to delete columns A, B from a dataframe df is del df['A'] and del df['B'] or df.drop(['A', 'B'], axis = 1).