๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ pandas โ€บ how-to-drop-rows-with-nan-values-in-pandas-dataframe
How to Drop Rows with NaN Values in Pandas DataFrame? - GeeksforGeeks
The dropna() method is the most straightforward way to remove rows with missing values. It scans through the DataFrame and drops any row that contains at least one NaN value.
Published: July 15, 2025
Top answer
1 of 16
1650

Don't drop, just take the rows where EPS is not NA:

df = df[df['EPS'].notna()]
2 of 16
1226

This question is already resolved, but...

...also consider the solution suggested by Wouter in his original comment. The ability to handle missing data, including dropna(), is built into pandas explicitly. Aside from potentially improved performance over doing it manually, these functions also come with a variety of options which may be useful.

In [24]: df = pd.DataFrame(np.random.randn(10,3))

In [25]: df.iloc[::2,0] = np.nan; df.iloc[::4,1] = np.nan; df.iloc[::3,2] = np.nan;

In [26]: df
Out[26]:
          0         1         2
0       NaN       NaN       NaN
1  2.677677 -1.466923 -0.750366
2       NaN  0.798002 -0.906038
3  0.672201  0.964789       NaN
4       NaN       NaN  0.050742
5 -1.250970  0.030561 -2.678622
6       NaN  1.036043       NaN
7  0.049896 -0.308003  0.823295
8       NaN       NaN  0.637482
9 -0.310130  0.078891       NaN

In [27]: df.dropna()     #drop all rows that have any NaN values
Out[27]:
          0         1         2
1  2.677677 -1.466923 -0.750366
5 -1.250970  0.030561 -2.678622
7  0.049896 -0.308003  0.823295

In [28]: df.dropna(how='all')     #drop only if ALL columns are NaN
Out[28]:
          0         1         2
1  2.677677 -1.466923 -0.750366
2       NaN  0.798002 -0.906038
3  0.672201  0.964789       NaN
4       NaN       NaN  0.050742
5 -1.250970  0.030561 -2.678622
6       NaN  1.036043       NaN
7  0.049896 -0.308003  0.823295
8       NaN       NaN  0.637482
9 -0.310130  0.078891       NaN

In [29]: df.dropna(thresh=2)   #Drop row if it does not have at least two values that are **not** NaN
Out[29]:
          0         1         2
1  2.677677 -1.466923 -0.750366
2       NaN  0.798002 -0.906038
3  0.672201  0.964789       NaN
5 -1.250970  0.030561 -2.678622
7  0.049896 -0.308003  0.823295
9 -0.310130  0.078891       NaN

In [30]: df.dropna(subset=[1])   #Drop only if NaN in specific column (as asked in the question)
Out[30]:
          0         1         2
1  2.677677 -1.466923 -0.750366
2       NaN  0.798002 -0.906038
3  0.672201  0.964789       NaN
5 -1.250970  0.030561 -2.678622
6       NaN  1.036043       NaN
7  0.049896 -0.308003  0.823295
9 -0.310130  0.078891       NaN

There are also other options (See docs at http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.dropna.html), including dropping columns instead of rows.

Pretty handy!

๐ŸŒ
IONOS
ionos.com โ€บ digital guide โ€บ websites โ€บ web development โ€บ python pandas: dataframe dropna()
How to clean data in pandas with dropna() - IONOS
June 26, 2025 - The Python pandas DataFrame.dropna() function is used to remove all rows or columns conยญtainยญing missing values (NaN) from a DataFrame.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ drop-rows-from-pandas-dataframe-with-missing-values-or-nan-in-columns
Drop rows from Pandas dataframe with missing values or NaN in columns - GeeksforGeeks
You can remove rows with at least one NaN (dropna()), rows where all values are NaN (dropna(how='all')), or columns with NaNs (dropna(axis=1)).
Published: July 15, 2025
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ how-to-drop-rows-with-nan-values-in-pandas-dataframe
How to Drop Rows with NaN Values in Pandas DataFrame? - GeeksforGeeks
The dropna() method is the most straightforward way to remove rows with missing values. It scans through the DataFrame and drops any row that contains at least one NaN value.
Published: April 17, 2025
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.dropna.html
pandas.DataFrame.dropna โ€” pandas 3.1.1 documentation
>>> df.dropna(how="all") name toy born 0 Alfred NaN NaT 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT ยท Keep only the rows with at least 2 non-NA values.
๐ŸŒ
Statistics Globe
statisticsglobe.com โ€บ home โ€บ python programming language for statistics & data science โ€บ remove rows with nan from pandas dataframe in python (4 examples)
Remove Rows with NaN in pandas DataFrame | Python Drop Missing Data
May 11, 2023 - In the following examples, Iโ€™ll explain how to remove some or all rows with NaN values. The following syntax explains how to delete all rows with at least one missing value using the dropna() function. Have a look at the following Python code ...
Find elsewhere
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ numpy
NumPy: Remove NaN (np.nan) from an array | note.nkmk.me
January 23, 2024 - By applying this ndarray to the rows (the first dimension) of the original ndarray, you can remove rows with NaN (extract rows without NaN).
๐ŸŒ
Pandas
pandas.pydata.org โ€บ pandas-docs โ€บ stable โ€บ reference โ€บ api โ€บ pandas.DataFrame.dropna.html
pandas.DataFrame.dropna โ€” pandas 3.1.0 documentation
>>> df.dropna(how="all") name toy born 0 Alfred NaN NaT 1 Batman Batmobile 1940-04-25 2 Catwoman Bullwhip NaT ยท Keep only the rows with at least 2 non-NA values.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 73633777 โ€บ how-to-delete-rows-which-has-nan-or-empty-value-in-specific-column
python - How to delete rows which has nan or empty value in SPECIFIC column? - Stack Overflow
I want to search according specific column. for example in column 3 row 25 it has nan or empty cell. then try to delete the entire row 25, but it should be according to Specific column. ... If need test third column (with index=2) use boolean indexing if nan is missing value np.nan or string nan:
๐ŸŒ
PythonForBeginners.com
pythonforbeginners.com โ€บ home โ€บ drop rows with nan values in a pandas dataframe
Drop Rows With Nan Values in a Pandas Dataframe - PythonForBeginners.com
December 18, 2022 - The thresh parameter is used when we want to drop rows if they have at least a specific number of non-NaN values present. For instance, if you want to delete a row if it has less than n non-null values, you can pass the number n to the thresh parameter.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ bytes โ€บ dropping-nan-values-in-pandas-dataframe
Dropping NaN Values in Pandas DataFrame
August 24, 2023 - For certain datasets, replacing ... In this Byte, we've covered how to identify and drop rows or columns with NaN values in a DataFrame using the dropna() function....
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ remove dataframe rows with missing values in python
Pandas dropna: Remove Rows with Missing Values in Python | Sentry
September 17, 2026 - Remove rows with missing values from a Pandas DataFrame using dropna with how=all to drop fully empty rows or how=any to drop rows with any NaN values