ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.statology.org/pandas-drop-columns-with-nan/ |
| Last Crawled | 2026-04-11 08:36:56 (3 hours ago) |
| First Indexed | 2023-01-03 16:36:31 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Pandas: How to Drop Columns with NaN Values |
| Meta Description | This tutorial explains how to drop columns in a pandas DataFrame with NaN values, including several examples. |
| Meta Canonical | null |
| Boilerpipe Text | You can use the following methods to drop columns from a pandas DataFrame with NaN values:
Method 1: Drop Columns with Any NaN Values
df = df.
dropna
(axis=
1
)
Method 2: Drop Columns with All NaN Values
df = df.
dropna
(axis=
1
, how='
all
')
Method 3: Drop Columns with Minimum Number of NaN Values
df = df.
dropna
(axis=
1
, thresh=
2
)
The following examples show how to use each method in practice with the following pandas DataFrame:
import
pandas
as
pd
import
numpy
as
np
#create DataFrame
df = pd.
DataFrame
({'
team
': ['A', 'A', 'A', 'B', 'B', 'B'],
'
position
': [np.nan, 'G', 'F', 'F', 'C', 'G'],
'
points
': [11, 28, 10, 26, 6, 25],
'
rebounds
': [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]})
#view DataFrame
print
(df)
team position points rebounds
0 A NaN 11 NaN
1 A G 28 NaN
2 A F 10 NaN
3 B F 26 NaN
4 B C 6 NaN
5 B G 25 NaN
Example 1: Drop Columns with Any NaN Values
The following code shows how to drop columns with any NaN values:
#drop columns with any NaN values
df = df.
dropna
(axis=
1
)
#view updated DataFrame
print
(df)
team points
0 A 11
1 A 28
2 A 10
3 B 26
4 B 6
5 B 25
Notice that the
position
and
rebounds
columns were dropped since they both had at least one NaN value.
Example 2: Drop Columns with All NaN Values
The following code shows how to drop columns with all NaN values:
#drop columns with all NaN values
df = df.
dropna
(axis=
1
, how='
all
')
#view updated DataFrame
print
(df)
team position points
0 A NaN 11
1 A G 28
2 A F 10
3 B F 26
4 B C 6
5 B G 25
Notice that the
rebounds
column was dropped since it was the only column with all NaN values.
Example 3: Drop Columns with Minimum Number of NaN Values
The following code shows how to drop columns with
at least two
NaN values:
#drop columns with at least two NaN values
df = df.
dropna
(axis=
1
, thresh=
2
)
#view updated DataFrame
print
(df)
team position points
0 A NaN 11
1 A G 28
2 A F 10
3 B F 26
4 B C 6
5 B G 25
Notice that the
rebounds
column was dropped since it was the only column with at least two NaN values.
Note
: You can find the complete documentation for the
dropna()
function in pandas
here
.
Additional Resources
The following tutorials explain how to perform other common tasks in pandas:
How to Drop First Column in Pandas
How to Drop Duplicate Columns in Pandas
How to Drop All Columns Except Specific Ones in Pandas
Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike. My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations. |
| Markdown | [](https://www.statology.org/)
- [About](https://www.statology.org/about/)
- [Course](https://www.statology.org/course-register/)
- [Basic Stats](https://www.statology.org/tutorials/)
- [Machine Learning](https://www.statology.org/machine-learning-tutorials/)
- [Software Tutorials]()
- [Excel](https://www.statology.org/excel-guides/)
- [Google Sheets](https://www.statology.org/google-sheets-guides/)
- [MongoDB](https://www.statology.org/mongodb-guides/)
- [MySQL](https://www.statology.org/mysql-guides/)
- [Power BI](https://www.statology.org/power-bi-guides/)
- [PySpark](https://www.statology.org/pyspark-guides/)
- [Python](https://www.statology.org/python-guides/)
- [R](https://www.statology.org/r-guides/)
- [SAS](https://www.statology.org/sas-guides/)
- [SPSS](https://www.statology.org/spss-guides/)
- [Stata](https://www.statology.org/stata-guides/)
- [TI-84](https://www.statology.org/ti-84-guides/)
- [VBA](https://www.statology.org/vba-guides/)
- [Tools]()
- [Calculators](https://www.statology.org/calculators/)
- [Critical Value Tables](https://www.statology.org/tables/)
- [Glossary](https://www.statology.org/glossary/)
# Pandas: How to Drop Columns with NaN Values
by [Zach Bobbitt](https://www.statology.org/author/admin/)
Published on
[Published on January 3, 2023](https://www.statology.org/pandas-drop-columns-with-nan/)
***
You can use the following methods to drop columns from a pandas DataFrame with NaN values:
**Method 1: Drop Columns with Any NaN Values**
```
df = df.dropna(axis=1)
```
**Method 2: Drop Columns with All NaN Values**
```
df = df.dropna(axis=1, how='all')
```
**Method 3: Drop Columns with Minimum Number of NaN Values**
```
df = df.dropna(axis=1, thresh=2)
```
The following examples show how to use each method in practice with the following pandas DataFrame:
```
import pandas as pd import numpy as np #create DataFrame df = pd.DataFrame({'team': ['A', 'A', 'A', 'B', 'B', 'B'], 'position': [np.nan, 'G', 'F', 'F', 'C', 'G'], 'points': [11, 28, 10, 26, 6, 25], 'rebounds': [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]}) #view DataFrame print(df) team position points rebounds 0 A NaN 11 NaN 1 A G 28 NaN 2 A F 10 NaN 3 B F 26 NaN 4 B C 6 NaN 5 B G 25 NaN
```
## **Example 1: Drop Columns with Any NaN Values**
The following code shows how to drop columns with any NaN values:
```
#drop columns with any NaN values df = df.dropna(axis=1) #view updated DataFrame print(df) team points 0 A 11 1 A 28 2 A 10 3 B 26 4 B 6 5 B 25
```
Notice that the **position** and **rebounds** columns were dropped since they both had at least one NaN value.
## **Example 2: Drop Columns with All NaN Values**
The following code shows how to drop columns with all NaN values:
```
#drop columns with all NaN values df = df.dropna(axis=1, how='all') #view updated DataFrame print(df) team position points 0 A NaN 11 1 A G 28 2 A F 10 3 B F 26 4 B C 6 5 B G 25
```
Notice that the **rebounds** column was dropped since it was the only column with all NaN values.
## **Example 3: Drop Columns with Minimum Number of NaN Values**
The following code shows how to drop columns with **at least two** NaN values:
```
#drop columns with at least two NaN values df = df.dropna(axis=1, thresh=2) #view updated DataFrame print(df) team position points 0 A NaN 11 1 A G 28 2 A F 10 3 B F 26 4 B C 6 5 B G 25
```
Notice that the **rebounds** column was dropped since it was the only column with at least two NaN values.
**Note**: You can find the complete documentation for the **dropna()** function in pandas [here](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dropna.html).
## **Additional Resources**
The following tutorials explain how to perform other common tasks in pandas:
[How to Drop First Column in Pandas](https://www.statology.org/pandas-drop-first-column/)
[How to Drop Duplicate Columns in Pandas](https://www.statology.org/pandas-drop-duplicate-columns/)
[How to Drop All Columns Except Specific Ones in Pandas](https://www.statology.org/pandas-drop-all-columns-except/)
Posted in [Programming](https://www.statology.org/category/programming/)

[Zach Bobbitt](https://www.statology.org/author/admin/)
Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike. My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations.
## Post navigation
[Prev Pandas: Extract Column Value Based on Another Column](https://www.statology.org/pandas-extract-column-value-based-on-another-column/)
[Next How to Normalize Values in NumPy Array Between 0 and 1](https://www.statology.org/numpy-normalize-between-0-and-1/)
### Leave a Reply [Cancel reply](https://www.statology.org/pandas-drop-columns-with-nan/#respond)
## Search
## ABOUT STATOLOGY
[](https://www.statology.org/about/)Statology makes learning statistics easy by explaining topics in simple and straightforward ways. Our team of writers have over 40 years of experience in the fields of Machine Learning, AI and Statistics. **[Learn more about our team here.](https://www.statology.org/about/)**
## Featured Posts
- [](https://www.statology.org/choosing-the-right-distance-metric-for-clustering-a-decision-tree-approach/)
[Choosing the Right Distance Metric for Clustering: A Decision Tree Approach](https://www.statology.org/choosing-the-right-distance-metric-for-clustering-a-decision-tree-approach/)
April 10, 2026
- [](https://www.statology.org/how-to-analyze-word-frequencies-with-textblob-in-python/)
[How to Analyze Word Frequencies with TextBlob in Python](https://www.statology.org/how-to-analyze-word-frequencies-with-textblob-in-python/)
April 9, 2026
- [](https://www.statology.org/from-raw-data-to-insight-with-copilot-across-the-microsoft-stack/)
[From Raw Data to Insight with Copilot Across the Microsoft Stack](https://www.statology.org/from-raw-data-to-insight-with-copilot-across-the-microsoft-stack/)
April 9, 2026
- [](https://www.statology.org/how-to-measure-subjectivity-in-text-with-textblob-in-python/)
[How to Measure Subjectivity in Text with TextBlob in Python](https://www.statology.org/how-to-measure-subjectivity-in-text-with-textblob-in-python/)
April 8, 2026
- [](https://www.statology.org/how-to-calculate-sentiment-polarity-scores-with-textblob-in-python/)
[How to Calculate Sentiment Polarity Scores with TextBlob in Python](https://www.statology.org/how-to-calculate-sentiment-polarity-scores-with-textblob-in-python/)
April 7, 2026
- [](https://www.statology.org/getting-started-with-textblob-in-python/)
[Getting Started with TextBlob in Python](https://www.statology.org/getting-started-with-textblob-in-python/)
April 7, 2026
## Statology Study
**[Statology Study](https://www.statology.org/study-register/)** is the ultimate online statistics study guide that helps you study and practice all of the core concepts taught in any elementary statistics course and makes your life so much easier as a student.
[](https://www.statology.org/study-register/)
## Introduction to Statistics Course
**Introduction to Statistics** is our premier online video course that teaches you all of the topics covered in introductory statistics. **[Get started](https://www.statology.org/course-register/)** with our course today.
[](https://www.statology.org/course-register/)
## You Might Also Like
- [Pandas: How to Use dropna() with thresh](https://www.statology.org/pandas-dropna-thresh/)
- [How to Drop Rows with NaN Values in Pandas](https://www.statology.org/drop-na-pandas/)
- [Pandas: How to Use dropna() with Specific Columns](https://www.statology.org/pandas-dropna-specific-column/)
- [Pandas: How to Reset Index After Using dropna()](https://www.statology.org/pandas-reset-index-after-dropna/)
- [How to Select Rows without NaN Values in Pandas](https://www.statology.org/pandas-select-rows-without-nan/)
- [How to Select Rows with NaN Values in Pandas (With Examples)](https://www.statology.org/pandas-select-rows-with-nan/)
© 2025 [Statology](https://www.statology.org/) \| [Privacy Policy](https://www.guidingtechmedia.com/privacy/) \| [Terms of Use](https://www.guidingtechmedia.com/terms-of-use/)
Wisteria Theme by [WPFriendship](https://wpfriendship.com/ "WPFriendship") ⋅ Powered by [WordPress](https://wordpress.org/ "WordPress") |
| Readable Markdown | ***
You can use the following methods to drop columns from a pandas DataFrame with NaN values:
**Method 1: Drop Columns with Any NaN Values**
```
df = df.dropna(axis=1)
```
**Method 2: Drop Columns with All NaN Values**
```
df = df.dropna(axis=1, how='all')
```
**Method 3: Drop Columns with Minimum Number of NaN Values**
```
df = df.dropna(axis=1, thresh=2)
```
The following examples show how to use each method in practice with the following pandas DataFrame:
```
import pandas as pd import numpy as np #create DataFrame df = pd.DataFrame({'team': ['A', 'A', 'A', 'B', 'B', 'B'], 'position': [np.nan, 'G', 'F', 'F', 'C', 'G'], 'points': [11, 28, 10, 26, 6, 25], 'rebounds': [np.nan, np.nan, np.nan, np.nan, np.nan, np.nan]}) #view DataFrame print(df) team position points rebounds 0 A NaN 11 NaN 1 A G 28 NaN 2 A F 10 NaN 3 B F 26 NaN 4 B C 6 NaN 5 B G 25 NaN
```
## **Example 1: Drop Columns with Any NaN Values**
The following code shows how to drop columns with any NaN values:
```
#drop columns with any NaN values df = df.dropna(axis=1) #view updated DataFrame print(df) team points 0 A 11 1 A 28 2 A 10 3 B 26 4 B 6 5 B 25
```
Notice that the **position** and **rebounds** columns were dropped since they both had at least one NaN value.
## **Example 2: Drop Columns with All NaN Values**
The following code shows how to drop columns with all NaN values:
```
#drop columns with all NaN values df = df.dropna(axis=1, how='all') #view updated DataFrame print(df) team position points 0 A NaN 11 1 A G 28 2 A F 10 3 B F 26 4 B C 6 5 B G 25
```
Notice that the **rebounds** column was dropped since it was the only column with all NaN values.
## **Example 3: Drop Columns with Minimum Number of NaN Values**
The following code shows how to drop columns with **at least two** NaN values:
```
#drop columns with at least two NaN values df = df.dropna(axis=1, thresh=2) #view updated DataFrame print(df) team position points 0 A NaN 11 1 A G 28 2 A F 10 3 B F 26 4 B C 6 5 B G 25
```
Notice that the **rebounds** column was dropped since it was the only column with at least two NaN values.
**Note**: You can find the complete documentation for the **dropna()** function in pandas [here](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dropna.html).
## **Additional Resources**
The following tutorials explain how to perform other common tasks in pandas:
[How to Drop First Column in Pandas](https://www.statology.org/pandas-drop-first-column/)
[How to Drop Duplicate Columns in Pandas](https://www.statology.org/pandas-drop-duplicate-columns/)
[How to Drop All Columns Except Specific Ones in Pandas](https://www.statology.org/pandas-drop-all-columns-except/)

Hey there. My name is Zach Bobbitt. I have a Masters of Science degree in Applied Statistics and I’ve worked on machine learning algorithms for professional businesses in both healthcare and retail. I’m passionate about statistics, machine learning, and data visualization and I created Statology to be a resource for both students and teachers alike. My goal with this site is to help you learn statistics through using simple terms, plenty of real-world examples, and helpful illustrations. |
| Shard | 80 (laksa) |
| Root Hash | 6121278954233998080 |
| Unparsed URL | org,statology!www,/pandas-drop-columns-with-nan/ s443 |