CBSE Class 12 Informatics Practices
Question 145 of 167
Python Pandas — I — Question 35
Back to all questionsThe error in the code is that topDf.del['Sec D'] is not the correct syntax to delete a row from a DataFrame in pandas. The correct syntax to delete a row in pandas is using the drop() method along with specifying the index label or index position of the row to be deleted.
The corrected code is:
>>> topDf.drop(['Sec D']) RollNo Name Marks
Sec A 115 Pavni 97.5
Sec B 236 Rishi 98.0
Sec C 307 Preet 98.5