Informatics Practices
Write statement(s) to delete a row from a DataFrame.
Python Pandas
6 Likes
Answer
The statement to delete a row from a DataFrame is:
<DF>.drop(index)
.
For example, the statement to delete the second row from a dataframe df
is df.drop(1)
.
Answered By
2 Likes
Related Questions
How would you add a new column namely 'val' to a dataframe df that has 10 rows in it and has columns as 'Item', 'Qty', 'Price' ? You can choose to put any values of your choice.
Write code statements for a dataframe df for the following :
(a) delete an existing column from it.
(b) delete rows from 3 to 6 from it.
(c) Check if the dataframe has any missing values.
(d) fill all missing values with 999 in it.
Write statement(s) to delete a column from a DataFrame.
Write statement(s) to change the value at 5th row, 6th column in a DataFrame df.