Search code examples
pythonpandasdataframedata-cleaning

How to remove rows with null values from a column?


I have small dataframe with null values in columns.

Movie Duration
Avatar 178
Spectre
John Carter 132
Tangled
Titanic 195

I can remove rows with null values for one column at a time with this command -

df.drop(df[df['duration'].isnull()].index)

But, suppose I had a large dataframe with hundreds of columns with null row values, then removing null row values for one column at a time is not possible.

What should be my approach in such a case?


Solution

  • As @Omniswitcher commented, df.drop() will work.

    pd.read_excel('Movie.xlsx').dropna(axis=0)
    

    Output: enter image description here