CBSE Class 12 Informatics Practices Question 43 of 44

Data Handling using Pandas — Question 44

Back to all questions
44
Question

Question 41

Differentiate between del, pop() and drop() functions.

Answer
del functionpop() functiondrop() function
The del statement deletes a column from a DataFrame.The pop() function is used to delete a column or an item from a DataFrame or Series.The drop() function is used to drop rows or columns from a DataFrame.
It does not return a value.It returns the removed item.It returns a new DataFrame with the dropped labels.
It modifies the original DataFrame or Series.It modifies the original DataFrame or Series.It does not modifies the original DataFrame by default (unless inplace = True is specified).
The syntax is del df['column_name'].The syntax is df['column_name'].pop().The syntax is df.drop(index or sequence of indexes).