CBSE Class 12 Informatics Practices Question 103 of 167

Python Pandas — I — Question 14

Back to all questions
14
Question

Question 14

Write statement(s) to delete a column from a DataFrame.

Answer

The statements to delete a column from a DataFrame is:

del <Df object>[<column name>]

OR

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

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