Informatics Practices
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.
Python Pandas
5 Likes
Answer
(a)
>>> del df[<column_name>]
(b)
>>> df.drop(range(2, 6))
(c)
>>> df.isnull()
(d)
>>> df.fillna(999)
Answered By
3 Likes
Related Questions
Hitesh wants to display the last four rows of the dataframe df and has written the following code :
df.tail()But last 5 rows are being displayed. Identify the error and rewrite the correct code so that last 4 rows get displayed.
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 statement(s) to delete a row from a DataFrame.
Write statement(s) to delete a column from a DataFrame.