âčïž 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://realpython.com/how-to-drop-null-values-in-pandas/ |
| Last Crawled | 2026-04-11 02:45:03 (19 hours ago) |
| First Indexed | 2025-08-26 16:35:29 (7 months ago) |
| HTTP Status Code | 200 |
| Meta Title | How to Drop Null Values in pandas With .dropna() â Real Python |
| Meta Description | Learn how to use .dropna() to drop null values from pandas DataFrames so you can clean missing data and keep your Python analysis accurate. |
| Meta Canonical | null |
| Boilerpipe Text | by
Ian Eyre
Publication date
Sep 10, 2025
Reading time estimate
18m
basics
data-science
python
Missing values can derail your analysis. In pandas, you can use the
.dropna()
method to remove rows or columns containing null valuesâin other words, missing dataâso you can work with clean DataFrames. In this tutorial, youâll learn how this methodâs parameters let you control exactly which data gets removed. As youâll see, these parameters give you fine-grained control over how much of your data to clean.
Dealing with null values is essential for keeping datasets clean and avoiding the issues they can cause. Missing entries can lead to misinterpreted column data types, inaccurate conclusions, and errors in calculations. Simply put, nulls can cause havoc if they find their way into your calculations.
By the end of this tutorial, youâll understand that:
You can use
.dropna()
to
remove rows and columns
from a pandas DataFrame.
You can remove rows and columns based on the
content of a subset
of your DataFrame.
You can remove rows and columns based on the
volume of null values
within your DataFrame.
To get the most out of this tutorial, itâs recommended that you already have a basic understanding of how to create
pandas DataFrames
from files.
Youâll use the Python
REPL
along with a file named
sales_data_with_missing_values.csv
, which contains several null values youâll deal with during the exercises. Before you start, extract this file from the downloadable materials by clicking the link at the end of this section.
The
sales_data_with_missing_values.csv
file is based on the publicly available and complete
sales data
file from
Kaggle
. Understanding the fileâs content isnât essential for this tutorial, but you can explore the Kaggle link above for more details if youâd like.
Youâll also need to install both the pandas and PyArrow libraries to make sure all code examples work in your environment:
Windows
Linux + macOS
Itâs time to refine your pandas skills by learning how to handle missing data in a variety of ways.
Youâll find all code examples and the
sales_data_with_missing_values.csv
file in the materials for this tutorial, which you can download by clicking the link below:
Take the Quiz:
Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
How to Drop Rows Containing Null Values With pandas
.dropna()
Before you start dropping rows, itâs helpful to know what options
.dropna()
gives you. This method supports six
parameters
that let you control exactly whatâs removed:
axis
: Specifies whether to remove rows or columns containing null values.
thresh
and
how
: Define how many missing values to remove or retain.
subset
: Limits the removal of null values to specific parts of your DataFrame.
inplace
: Determines whether the operation modifies the original DataFrame or returns a new copy.
ignore_index
: Resets the DataFrame index after removing rows.
Donât worry if any of these parameters donât make sense to you just yetâyouâll learn why each is used during this tutorial. Youâll also get the chance to practice your skills.
Before using
.dropna()
to drop rows, you should first find out whether your data contains any
null values
:
To make sure all columns appear on your screen, you configure
pd.set_option("display.max_columns", None)
. By passing
None
as the second parameter, you make sure all columns are displayed.
You read the
sales_data_with_missing_values.csv
file into a DataFrame using the
pandas
read_csv()
function, then view the data. The order dates are in the
"%d/%m/%Y"
format in the file, so to make sure the
order_date
data is read correctly, you use both the
parse_dates
and
date_format
parameters. The output reveals there are ten rows and six columns of data in your file.
In a real
data analysis
, your DataFrame may be too large to allow you to see everything thatâs missing. To solve this, you use the DataFrameâs
.isna()
and
.sum()
methods together:
As you can see, each of your columns is missing data.
When you use
sales_data.isna()
, you create a
Boolean
DataFrame the same size as
sales_data
, but with null values replaced with
True
and everything else replaced with
False
. The
.sum()
method counts each
True
and returns it to you as shown.
To remove the rows with null values, you use
.dropna()
:
As you can see, rows with null values are nowhere to be seen.
You might think the rows containing the null values from
sales_data
have been deleted. After all, thatâs what the output shows. However, this isnât true. When you use
sales_data.dropna()
, the results are placed into a new DataFrame, leaving the original unchanged. If you want to retain this second DataFrame, then you need to assign the output from
.dropna()
to a new variable:
Now the
clean_sales_data
DataFrame contains a second copy of the original
sales_data
DataFrame, but without those rows that contained one or more null values. Of course, this is wasteful of memory, so a better option would be to update the original DataFrame. To do this, you pass
inplace=True
to
.dropna()
:
The original
sales_data
DataFrame will no longer contain rows with null values, and any future analysis will occur against this new version.
Youâve now seen the basic use case for
.dropna()
, where you drop rows with at least one missing value. But the method also includes several other parameters worth exploring.
How to Drop Columns Containing Null Values With pandas
.dropna()
So far, youâve seen how to drop rows containing missing values, but itâs also possible to drop incomplete columns. You do this using the
axis
parameter. By default,
axis
is set to
0
, or
"index"
, which means it operates on rows of data. If you want to apply it across columns, then you set
axis
to
1
or
"columns"
.
Suppose you want to remove
incomplete columns
containing null values from the original
sales_data
. Hereâs how you do it:
Because every column has at least one missing value, theyâve all been removed, leaving the DataFrame empty except for its index.
So far, youâve taken a fairly aggressive approach by removing entire rows and columns. Next, youâll look at some less destructive alternatives.
How to Work With a Part of Your Data
Earlier, you used
.dropna()
to remove all null values from your DataFrame. While this is a common use case, you can also remove nulls from specific parts of the DataFrame or based on a certain quantity threshold. Youâll learn how in this section.
Removing Data Based on Specific Rows or Columns
You can restrict removal of data based on the rows or columns where the null values appear. This is where the
subset
parameter comes in handy.
By passing a
column label
or a sequence of labels to
subset
, you tell
.dropna()
which columns to check for null values and remove their associated rows. Similarly, by passing
subset
an
index position
or a sequence of index positions and setting
axis="columns"
, you remove the column or columns that contain null values at the specified index positions.
For example, suppose you want to remove rows containing null values in either the
discount
or
sale_price columns
. If there are null values in other columns besides
discount
or
sale_price
, then those rows will remain untouched. Hereâs how you do it:
This time, youâve removed four rows. To clarify that youâre removing rows, you explicitly set
axis
to
0
. However, you can omit this argument since
0
is the default value for the
axis
parameter. To restrict your analysis to the two columns you want, you pass the Python list
["discount", "sale_price"]
as the
subset
parameter.
Removing Data Based on the Quantity of Missing Values
Itâs possible to instruct
.dropna()
to remove rows or columns based on a specified quantity of data. Suppose youâre concerned about the volume of data missing in your DataFrame. Youâre worried about rows with
more than
one missing value. In other words, you want to delete those rows containing at least five pieces of data in their six columns.
To do this, you can set this threshold using the
thresh
parameter:
Rows with indices
1
and
9
have been removed since they contain multiple missing values. By setting
thresh
to
5
, you tell
.dropna()
to keep all rows that contain at least five values. Since there are six columns, all remaining rows have no more than one missing value.
Removing Empty Rows or Columns
Sometimes you might want to remove only rows or columns that are completely empty, rather than those with just some missing values. You can control this with the
how
parameter.
For example, suppose you want to remove rows where all values are missing:
As you can see, the blank row at index position
9
has been removed. By passing
how="all"
to
.dropna()
and using the default value
axis=0
, you remove rows containing only null values. Alternatively, you could pass
how="any"
to remove rows or columns that have at least one null value. You rarely need to do this, however, because
"any"
is the default value.
Adding a Finishing Touch: Reset the Index
Finally, you may have noticed that each time you remove a rowâboth here and throughout this tutorialâthe index doesnât update. As a finishing touch, passing
ignore_index=True
will reindex your DataFrame sequentially:
This time, the index starts at
0
and ends at
8
, and there are only nine rows remaining.
To wrap up what youâve covered so far, itâs time to test your new skills.
Practice Your pandas
.dropna()
Skills
To practice, begin by loading the contents of
grades.csv
into a DataFrame:
The DataFrame shows results for six students in five subjects. In this case,
<NA>
indicates that an exam wasnât taken.
Now, see if you can use
.dropna()
to answer each of the following questions:
Use
.dropna()
so that it permanently drops the row in the DataFrame containing only null values. Use this version from this point on.
Display the rows for the exams that all students completed.
Display any columns with no missing data.
Display the exams taken by at least five students.
Identify who else completed every exam that both S2 and S4 took.
Youâll find the answers in the downloadable materials below:
Conclusion
During this tutorial, you learned to use the DataFrameâs
.dropna()
method to remove null values from your DataFrames.
By using the various parameters, youâve learned how:
The
axis
parameter allows you to
remove rows or columns
containing null values.
The
thresh
and
how
parameters allow you to
define the quantity
of what gets removed.
The
subset
parameter lets you
restrict the removal
to part of your DataFrame.
The
inplace
parameter allows you to update either the
original DataFrame or a copy
after deletions.
The
ignore_index
parameter allows you to
reset the DataFrame index
after rows of data have been removed.
Although you now have a solid understanding of
.dropna()
, thereâs still lots to explore.
Review what youâve learned here to identify which techniques best fit your needs for handling missing values. You may also want to apply these skills to the
.dropna()
methods for pandas Series and Index objects. Doing so is a great way to continue your learning journey.
Take the Quiz:
Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
Frequently Asked Questions
Now that you have some experience with dropping null values in pandas, you can use the questions and answers below to check your understanding and recap what youâve learned.
These FAQs are related to the most important concepts youâve covered in this tutorial. Click the
Show/Hide
toggle beside each question to reveal the answer.
You use the
.dropna()
method to remove rows or columns with null values from your DataFrame.
You remove empty values by using the
.dropna()
method, which lets you drop rows or columns containing null values.
You use the
thresh
parameter to specify the minimum number of non-null values a row or column must have to avoid being dropped.
You set the
axis
parameter to
1
or
"columns"
in the
.dropna()
method to drop columns containing null values.
When you set
inplace=True
, you update the original DataFrame directly, removing rows or columns with null values without creating a new DataFrame. |
| Markdown | [](https://realpython.com/)
- [Start Here](https://realpython.com/start-here/)
- [Learn Python](https://realpython.com/how-to-drop-null-values-in-pandas/)
[Python Tutorials â In-depth articles and video courses](https://realpython.com/search?kind=article&kind=course&order=newest)
[Learning Paths â Guided study plans for accelerated learning](https://realpython.com/learning-paths/)
[Quizzes & Exercises â Check your learning progress](https://realpython.com/quizzes/)
[Browse Topics â Focus on a specific area or skill level](https://realpython.com/tutorials/all/)
[Community Chat â Learn with other Pythonistas](https://realpython.com/community/)
[Office Hours â Live Q\&A calls with Python experts](https://realpython.com/office-hours/)
[Live Courses â Live, instructor-led Python courses](https://realpython.com/live/)
[Podcast â Hear whatâs new in the world of Python](https://realpython.com/podcasts/rpp/)
[Books â Round out your knowledge and learn offline](https://realpython.com/products/books/)
[Reference â Concise definitions for common Python terms](https://realpython.com/ref/)
[Code Mentor âBeta Personalized code assistance & learning tools](https://realpython.com/mentor/)
[Unlock All Content â](https://realpython.com/account/join/)
- [More](https://realpython.com/how-to-drop-null-values-in-pandas/)
[Learner Stories](https://realpython.com/learner-stories/) [Python Newsletter](https://realpython.com/newsletter/) [Python Job Board](https://www.pythonjobshq.com/) [Meet the Team](https://realpython.com/team/) [Become a Contributor](https://realpython.com/jobs/)
- [Search](https://realpython.com/search "Search")
- [Join](https://realpython.com/account/join/)
- [SignâIn](https://realpython.com/account/login/?next=%2Fhow-to-drop-null-values-in-pandas%2F)
[Browse Topics](https://realpython.com/tutorials/all/)
[Guided Learning Paths](https://realpython.com/learning-paths/)
[Basics](https://realpython.com/search?level=basics)
[Intermediate](https://realpython.com/search?level=intermediate)
[Advanced](https://realpython.com/search?level=advanced)
***
[ai](https://realpython.com/tutorials/ai/) [algorithms](https://realpython.com/tutorials/algorithms/) [api](https://realpython.com/tutorials/api/) [best-practices](https://realpython.com/tutorials/best-practices/) [career](https://realpython.com/tutorials/career/) [community](https://realpython.com/tutorials/community/) [databases](https://realpython.com/tutorials/databases/) [data-science](https://realpython.com/tutorials/data-science/) [data-structures](https://realpython.com/tutorials/data-structures/) [data-viz](https://realpython.com/tutorials/data-viz/) [devops](https://realpython.com/tutorials/devops/) [django](https://realpython.com/tutorials/django/) [docker](https://realpython.com/tutorials/docker/) [editors](https://realpython.com/tutorials/editors/) [flask](https://realpython.com/tutorials/flask/) [front-end](https://realpython.com/tutorials/front-end/) [gamedev](https://realpython.com/tutorials/gamedev/) [gui](https://realpython.com/tutorials/gui/) [machine-learning](https://realpython.com/tutorials/machine-learning/) [news](https://realpython.com/tutorials/news/) [numpy](https://realpython.com/tutorials/numpy/) [projects](https://realpython.com/tutorials/projects/) [python](https://realpython.com/tutorials/python/) [stdlib](https://realpython.com/tutorials/stdlib/) [testing](https://realpython.com/tutorials/testing/) [tools](https://realpython.com/tutorials/tools/) [web-dev](https://realpython.com/tutorials/web-dev/) [web-scraping](https://realpython.com/tutorials/web-scraping/)
[Table of Contents](https://realpython.com/how-to-drop-null-values-in-pandas/#toc)
- [How to Drop Rows Containing Null Values With pandas .dropna()](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-drop-rows-containing-null-values-with-pandas-dropna)
- [How to Drop Columns Containing Null Values With pandas .dropna()](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-drop-columns-containing-null-values-with-pandas-dropna)
- [How to Work With a Part of Your Data](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-work-with-a-part-of-your-data)
- [Removing Data Based on Specific Rows or Columns](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-data-based-on-specific-rows-or-columns)
- [Removing Data Based on the Quantity of Missing Values](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-data-based-on-the-quantity-of-missing-values)
- [Removing Empty Rows or Columns](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-empty-rows-or-columns)
- [Adding a Finishing Touch: Reset the Index](https://realpython.com/how-to-drop-null-values-in-pandas/#adding-a-finishing-touch-reset-the-index)
- [Practice Your pandas .dropna() Skills](https://realpython.com/how-to-drop-null-values-in-pandas/#practice-your-pandas-dropna-skills)
- [Conclusion](https://realpython.com/how-to-drop-null-values-in-pandas/#conclusion)
- [Frequently Asked Questions](https://realpython.com/how-to-drop-null-values-in-pandas/#frequently-asked-questions)
Mark as Completed
Share

# How to Drop Null Values in pandas With .dropna()
by [Ian Eyre](https://realpython.com/how-to-drop-null-values-in-pandas/#author)
Publication date
Sep 10, 2025
Reading time estimate
18m
[0 Comments](https://realpython.com/how-to-drop-null-values-in-pandas/#reader-comments)
[basics](https://realpython.com/tutorials/basics/) [data-science](https://realpython.com/tutorials/data-science/) [python](https://realpython.com/tutorials/python/)
Mark as Completed
Share
Table of Contents
- [How to Drop Rows Containing Null Values With pandas .dropna()](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-drop-rows-containing-null-values-with-pandas-dropna)
- [How to Drop Columns Containing Null Values With pandas .dropna()](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-drop-columns-containing-null-values-with-pandas-dropna)
- [How to Work With a Part of Your Data](https://realpython.com/how-to-drop-null-values-in-pandas/#how-to-work-with-a-part-of-your-data)
- [Removing Data Based on Specific Rows or Columns](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-data-based-on-specific-rows-or-columns)
- [Removing Data Based on the Quantity of Missing Values](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-data-based-on-the-quantity-of-missing-values)
- [Removing Empty Rows or Columns](https://realpython.com/how-to-drop-null-values-in-pandas/#removing-empty-rows-or-columns)
- [Adding a Finishing Touch: Reset the Index](https://realpython.com/how-to-drop-null-values-in-pandas/#adding-a-finishing-touch-reset-the-index)
- [Practice Your pandas .dropna() Skills](https://realpython.com/how-to-drop-null-values-in-pandas/#practice-your-pandas-dropna-skills)
- [Conclusion](https://realpython.com/how-to-drop-null-values-in-pandas/#conclusion)
- [Frequently Asked Questions](https://realpython.com/how-to-drop-null-values-in-pandas/#frequently-asked-questions)
[Remove ads](https://realpython.com/account/join/)
Missing values can derail your analysis. In pandas, you can use the `.dropna()` method to remove rows or columns containing null valuesâin other words, missing dataâso you can work with clean DataFrames. In this tutorial, youâll learn how this methodâs parameters let you control exactly which data gets removed. As youâll see, these parameters give you fine-grained control over how much of your data to clean.
Dealing with null values is essential for keeping datasets clean and avoiding the issues they can cause. Missing entries can lead to misinterpreted column data types, inaccurate conclusions, and errors in calculations. Simply put, nulls can cause havoc if they find their way into your calculations.
**By the end of this tutorial, youâll understand that:**
- You can use **`.dropna()`** to **remove rows and columns** from a pandas DataFrame.
- You can remove rows and columns based on the **content of a subset** of your DataFrame.
- You can remove rows and columns based on the **volume of null values** within your DataFrame.
To get the most out of this tutorial, itâs recommended that you already have a basic understanding of how to create [pandas DataFrames](https://realpython.com/pandas-dataframe/) from files.
Youâll use the Python [REPL](https://realpython.com/ref/glossary/repl/) along with a file named `sales_data_with_missing_values.csv`, which contains several null values youâll deal with during the exercises. Before you start, extract this file from the downloadable materials by clicking the link at the end of this section.
The `sales_data_with_missing_values.csv` file is based on the publicly available and complete [sales data](https://www.kaggle.com/datasets/satyamanidharv/sales-data-presentation-dashboards?resource=download) file from [Kaggle](https://www.kaggle.com/). Understanding the fileâs content isnât essential for this tutorial, but you can explore the Kaggle link above for more details if youâd like.
Youâll also need to install both the pandas and PyArrow libraries to make sure all code examples work in your environment:
- [Windows](https://realpython.com/how-to-drop-null-values-in-pandas/#windows-1)
- [Linux + macOS](https://realpython.com/how-to-drop-null-values-in-pandas/#linux-macos-1)
Windows PowerShell
```
PS> python -m pip install pandas pyarrow
```
Shell
```
$ python -m pip install pandas pyarrow
```
Itâs time to refine your pandas skills by learning how to handle missing data in a variety of ways.
Youâll find all code examples and the `sales_data_with_missing_values.csv` file in the materials for this tutorial, which you can download by clicking the link below:
**Get Your Code:** [Click here to download the free sample code](https://realpython.com/bonus/how-to-drop-null-values-in-pandas-code/) that youâll use to learn how to drop null values in pandas.
***Take the Quiz:*** Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
***
[](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
**Interactive Quiz**
[How to Drop Null Values in pandas](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
Quiz yourself on pandas .dropna(): remove nulls, clean missing data, and prepare DataFrames for accurate analysis.
## How to Drop Rows Containing Null Values With pandas `.dropna()`
Before you start dropping rows, itâs helpful to know what options `.dropna()` gives you. This method supports six **parameters** that let you control exactly whatâs removed:
- **`axis`**: Specifies whether to remove rows or columns containing null values.
- **`thresh`** and **`how`**: Define how many missing values to remove or retain.
- **`subset`**: Limits the removal of null values to specific parts of your DataFrame.
- **`inplace`**: Determines whether the operation modifies the original DataFrame or returns a new copy.
- **`ignore_index`**: Resets the DataFrame index after removing rows.
Donât worry if any of these parameters donât make sense to you just yetâyouâll learn why each is used during this tutorial. Youâll also get the chance to practice your skills.
**Note:** Although this tutorial teaches you how pandas DataFrames use `.dropna()`, DataFrames arenât the only pandas objects that use it.
[Series](https://pandas.pydata.org/docs/reference/series.html) objects also have their own [`.dropna()`](https://pandas.pydata.org/docs/reference/api/pandas.Series.dropna.html) method. However, the Series version contains only four parametersâ`axis`, `inplace`, `how`, and `ignore_index`âinstead of the six supported by the DataFrame version. Of these, only `inplace` and `ignore_index` are used, and they work the same way as in the DataFrame method. The rest are kept for compatibility with DataFrame, but have no effect.
[Indexes](https://pandas.pydata.org/docs/reference/indexing.html) also have a [`.dropna()`](https://pandas.pydata.org/docs/reference/api/pandas.Index.dropna.html) method for removing missing index values, and it contains just one parameter: `how`.
Before using `.dropna()` to drop rows, you should first find out whether your data contains any [null values](https://realpython.com/null-in-python/):
Python
```
```
To make sure all columns appear on your screen, you configure `pd.set_option("display.max_columns", None)`. By passing `None` as the second parameter, you make sure all columns are displayed.
You read the `sales_data_with_missing_values.csv` file into a DataFrame using the [pandas `read_csv()`](https://realpython.com/pandas-read-write-files/#read-a-csv-file) function, then view the data. The order dates are in the `"%d/%m/%Y"` format in the file, so to make sure the `order_date` data is read correctly, you use both the `parse_dates` and `date_format` parameters. The output reveals there are ten rows and six columns of data in your file.
**Note:** By default, pandas uses the [NumPy](https://realpython.com/numpy-tutorial/) library for its back-end data types. In the futureâstarting with [pandas 3](https://github.com/pandas-dev/pandas/milestone/102), which is under developmentâthe default back end will be the more efficient [PyArrow](https://pandas.pydata.org/docs/user_guide/pyarrow.html). You can still get the benefits of this new back end and its [data types](https://arrow.apache.org/docs/python/api/datatypes) by configuring pandas using the `.convert_dtypes(dtype_backend="pyarrow")` method on your DataFrame.
Using PyArrow also means the null values are displayed consistently as `<NA>`. If you use the default NumPy back end, then the null value in `order_date` would display as `NaT`, for *not a time*, while the rest would be shown as `NaN`, for *not a number*. Fortunately, `.dropna()` treats them all as null values.
In a real [data analysis](https://realpython.com/python-for-data-analysis/), your DataFrame may be too large to allow you to see everything thatâs missing. To solve this, you use the DataFrameâs [`.isna()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isna.html) and [`.sum()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sum.html) methods together:
Python
```
```
As you can see, each of your columns is missing data.
When you use `sales_data.isna()`, you create a [Boolean](https://realpython.com/ref/glossary/boolean/) DataFrame the same size as `sales_data`, but with null values replaced with `True` and everything else replaced with `False`. The `.sum()` method counts each `True` and returns it to you as shown.
**Note:** You may see [`.isnull()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isnull.html) being used. This is an alias for `.isna()`, and both work the same way. In addition, pandas provides [`.notna()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.notna.html) and [`.notnull()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.notnull.html), which you can use to reveal how many values in each column *donât* contain nulls.
To remove the rows with null values, you use [`.dropna()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dropna.html):
Python
```
```
As you can see, rows with null values are nowhere to be seen.
You might think the rows containing the null values from `sales_data` have been deleted. After all, thatâs what the output shows. However, this isnât true. When you use `sales_data.dropna()`, the results are placed into a new DataFrame, leaving the original unchanged. If you want to retain this second DataFrame, then you need to assign the output from `.dropna()` to a new variable:
Python
```
>>> clean_sales_data = sales_data.dropna()
```
Now the `clean_sales_data` DataFrame contains a second copy of the original `sales_data` DataFrame, but without those rows that contained one or more null values. Of course, this is wasteful of memory, so a better option would be to update the original DataFrame. To do this, you pass `inplace=True` to `.dropna()`:
Python
```
>>> sales_data.dropna(inplace=True)
```
The original `sales_data` DataFrame will no longer contain rows with null values, and any future analysis will occur against this new version.
**Note:** Even though `inplace=True` allows you to save memory, it offers little performance benefit during processing because a temporary copy is still made in the background. Also, applying some of your processing to your original DataFrame and some to a second copy can make finding errors difficult. A [pandas enhancement proposal (PDEP)](https://pandas.pydata.org/pdeps/0008-inplace-methods-in-pandas.html) calling for a deprecation was created because of these issues.
Setting `inplace=True` is most useful when you want to make a one-time permanent change to your data and then use that version in all future analysis.
Youâve now seen the basic use case for `.dropna()`, where you drop rows with at least one missing value. But the method also includes several other parameters worth exploring.
[Remove ads](https://realpython.com/account/join/)
## How to Drop Columns Containing Null Values With pandas `.dropna()`
So far, youâve seen how to drop rows containing missing values, but itâs also possible to drop incomplete columns. You do this using the `axis` parameter. By default, `axis` is set to `0`, or `"index"`, which means it operates on rows of data. If you want to apply it across columns, then you set `axis` to `1` or `"columns"`.
Suppose you want to remove **incomplete columns** containing null values from the original `sales_data`. Hereâs how you do it:
Python
```
```
Because every column has at least one missing value, theyâve all been removed, leaving the DataFrame empty except for its index.
So far, youâve taken a fairly aggressive approach by removing entire rows and columns. Next, youâll look at some less destructive alternatives.
## How to Work With a Part of Your Data
Earlier, you used `.dropna()` to remove all null values from your DataFrame. While this is a common use case, you can also remove nulls from specific parts of the DataFrame or based on a certain quantity threshold. Youâll learn how in this section.
### Removing Data Based on Specific Rows or Columns
You can restrict removal of data based on the rows or columns where the null values appear. This is where the `subset` parameter comes in handy.
By passing a **column label** or a sequence of labels to `subset`, you tell `.dropna()` which columns to check for null values and remove their associated rows. Similarly, by passing `subset` an **index position** or a sequence of index positions and setting `axis="columns"`, you remove the column or columns that contain null values at the specified index positions.
For example, suppose you want to remove rows containing null values in either the `discount` or `sale_price columns`. If there are null values in other columns besides `discount` or `sale_price`, then those rows will remain untouched. Hereâs how you do it:
Python
```
```
This time, youâve removed four rows. To clarify that youâre removing rows, you explicitly set `axis` to `0`. However, you can omit this argument since `0` is the default value for the `axis` parameter. To restrict your analysis to the two columns you want, you pass the Python list `["discount", "sale_price"]` as the `subset` parameter.
### Removing Data Based on the Quantity of Missing Values
Itâs possible to instruct `.dropna()` to remove rows or columns based on a specified quantity of data. Suppose youâre concerned about the volume of data missing in your DataFrame. Youâre worried about rows with *more than* one missing value. In other words, you want to delete those rows containing at least five pieces of data in their six columns.
To do this, you can set this threshold using the `thresh` parameter:
Python
```
```
Rows with indices `1` and `9` have been removed since they contain multiple missing values. By setting `thresh` to `5`, you tell `.dropna()` to keep all rows that contain at least five values. Since there are six columns, all remaining rows have no more than one missing value.
### Removing Empty Rows or Columns
Sometimes you might want to remove only rows or columns that are completely empty, rather than those with just some missing values. You can control this with the `how` parameter.
For example, suppose you want to remove rows where all values are missing:
Python
```
```
As you can see, the blank row at index position `9` has been removed. By passing `how="all"` to `.dropna()` and using the default value `axis=0`, you remove rows containing only null values. Alternatively, you could pass `how="any"` to remove rows or columns that have at least one null value. You rarely need to do this, however, because `"any"` is the default value.
**Note:** The `how` and `thresh` parameters are mutually exclusive. In other words, you can use one or the other, but not both at the same time. It isnât logical to specify `"any"` or `"all"` and then also set a threshold.
[Remove ads](https://realpython.com/account/join/)
### Adding a Finishing Touch: Reset the Index
Finally, you may have noticed that each time you remove a rowâboth here and throughout this tutorialâthe index doesnât update. As a finishing touch, passing `ignore_index=True` will reindex your DataFrame sequentially:
Python
```
```
This time, the index starts at `0` and ends at `8`, and there are only nine rows remaining.
To wrap up what youâve covered so far, itâs time to test your new skills.
## Practice Your pandas `.dropna()` Skills
To practice, begin by loading the contents of `grades.csv` into a DataFrame:
Python
```
```
The DataFrame shows results for six students in five subjects. In this case, `<NA>` indicates that an exam wasnât taken.
Now, see if you can use `.dropna()` to answer each of the following questions:
1. Use `.dropna()` so that it permanently drops the row in the DataFrame containing only null values. Use this version from this point on.
2. Display the rows for the exams that all students completed.
3. Display any columns with no missing data.
4. Display the exams taken by at least five students.
5. Identify who else completed every exam that both S2 and S4 took.
Youâll find the answers in the downloadable materials below:
**Get Your Code:** [Click here to download the free sample code](https://realpython.com/bonus/how-to-drop-null-values-in-pandas-code/) that youâll use to learn how to drop null values in pandas.
## Conclusion
During this tutorial, you learned to use the DataFrameâs `.dropna()` method to remove null values from your DataFrames.
**By using the various parameters, youâve learned how:**
- The `axis` parameter allows you to **remove rows or columns** containing null values.
- The `thresh` and `how` parameters allow you to **define the quantity** of what gets removed.
- The `subset` parameter lets you **restrict the removal** to part of your DataFrame.
- The `inplace` parameter allows you to update either the **original DataFrame or a copy** after deletions.
- The `ignore_index` parameter allows you to **[reset the DataFrame index](https://realpython.com/pandas-reset-index/)** after rows of data have been removed.
Although you now have a solid understanding of `.dropna()`, thereâs still lots to explore.
Review what youâve learned here to identify which techniques best fit your needs for handling missing values. You may also want to apply these skills to the `.dropna()` methods for pandas Series and Index objects. Doing so is a great way to continue your learning journey.
***Take the Quiz:*** Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
***
[](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
**Interactive Quiz**
[How to Drop Null Values in pandas](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
Quiz yourself on pandas .dropna(): remove nulls, clean missing data, and prepare DataFrames for accurate analysis.
[Remove ads](https://realpython.com/account/join/)
## Frequently Asked Questions
Now that you have some experience with dropping null values in pandas, you can use the questions and answers below to check your understanding and recap what youâve learned.
These FAQs are related to the most important concepts youâve covered in this tutorial. Click the *Show/Hide* toggle beside each question to reveal the answer.
**How do you drop null values in a pandas DataFrame?**Show/Hide
You use the `.dropna()` method to remove rows or columns with null values from your DataFrame.
**How can you remove empty values in pandas?**Show/Hide
You remove empty values by using the `.dropna()` method, which lets you drop rows or columns containing null values.
**What is the `thresh` parameter used for in `.dropna()`?**Show/Hide
You use the `thresh` parameter to specify the minimum number of non-null values a row or column must have to avoid being dropped.
**How do you drop columns with missing data in pandas?**Show/Hide
You set the `axis` parameter to `1` or `"columns"` in the `.dropna()` method to drop columns containing null values.
**What happens when you set `inplace=True` in `.dropna()`?**Show/Hide
When you set `inplace=True`, you update the original DataFrame directly, removing rows or columns with null values without creating a new DataFrame.
Mark as Completed
Share
đ Python Tricks đ
Get a short & sweet **Python Trick** delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

About **Ian Eyre**
[ ](https://realpython.com/team/ieyre/)
Ian is an avid Pythonista and Real Python contributor who loves to learn and teach others.
[» More about Ian](https://realpython.com/team/ieyre/)
***
*Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:*
[](https://realpython.com/team/asantos/)
[Aldren](https://realpython.com/team/asantos/)
[](https://realpython.com/team/bweleschuk/)
[Brenda](https://realpython.com/team/bweleschuk/)
[](https://realpython.com/team/bzaczynski/)
[Bartosz](https://realpython.com/team/bzaczynski/)
[](https://realpython.com/team/sgruppetta/)
[Stephen](https://realpython.com/team/sgruppetta/)
Master Real-World Python Skills With Unlimited Access to Real Python

**Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:**
[Level Up Your Python Skills »](https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=how-to-drop-null-values-in-pandas)
Master Real-World Python Skills
With Unlimited Access to Real Python

**Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:**
[Level Up Your Python Skills »](https://realpython.com/account/join/?utm_source=rp_article_footer&utm_content=how-to-drop-null-values-in-pandas)
What Do You Think?
**Rate this article:**
[LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Frealpython.com%2Fhow-to-drop-null-values-in-pandas%2F)
[Twitter](https://twitter.com/intent/tweet/?text=Interesting%20Python%20article%20on%20%40realpython%3A%20How%20to%20Drop%20Null%20Values%20in%20pandas%20With%20.dropna%28%29&url=https%3A%2F%2Frealpython.com%2Fhow-to-drop-null-values-in-pandas%2F)
[Bluesky](https://bsky.app/intent/compose?text=Interesting%20Python%20article%20on%20%40realpython.com%3A%20How%20to%20Drop%20Null%20Values%20in%20pandas%20With%20.dropna%28%29%20https%3A%2F%2Frealpython.com%2Fhow-to-drop-null-values-in-pandas%2F)
[Facebook](https://facebook.com/sharer/sharer.php?u=https%3A%2F%2Frealpython.com%2Fhow-to-drop-null-values-in-pandas%2F)
[Email](mailto:?subject=Python%20article%20for%20you&body=How%20to%20Drop%20Null%20Values%20in%20pandas%20With%20.dropna%28%29%20on%20Real%20Python%0A%0Ahttps%3A%2F%2Frealpython.com%2Fhow-to-drop-null-values-in-pandas%2F%0A)
Whatâs your \#1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.
**Commenting Tips:** The most useful comments are those written with the goal of learning from or helping out other students. [Get tips for asking good questions](https://realpython.com/python-beginner-tips/#tip-9-ask-good-questions) and [get answers to common questions in our support portal](https://support.realpython.com/).
***
Looking for a real-time conversation? Visit the [Real Python Community Chat](https://realpython.com/community/) or join the next [âOffice Hoursâ Live Q\&A Session](https://realpython.com/office-hours/). Happy Pythoning\!
Keep Learning
Related Topics: [basics](https://realpython.com/tutorials/basics/) [data-science](https://realpython.com/tutorials/data-science/) [python](https://realpython.com/tutorials/python/)
## Keep reading Real Python by creating a free account or signing in:
[](https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fhow-to-drop-null-values-in-pandas%2F)
[Continue »](https://realpython.com/account/signup/?intent=continue_reading&utm_source=rp&utm_medium=web&utm_campaign=rwn&utm_content=v1&next=%2Fhow-to-drop-null-values-in-pandas%2F)
Already have an account? [Sign-In](https://realpython.com/account/login/?next=/how-to-drop-null-values-in-pandas/)
Almost there! Complete this form and click the button below to gain instant access:
Ă

How to Drop Null Values in pandas (Sample Code)
##### Learn Python
- [Start Here](https://realpython.com/start-here/)
- [Learning Resources](https://realpython.com/search)
- [Code Mentor](https://realpython.com/mentor/)
- [Python Reference](https://realpython.com/ref/)
- [Python Cheat Sheet](https://realpython.com/cheatsheets/python/)
- [Support Center](https://support.realpython.com/)
##### Courses & Paths
- [Learning Paths](https://realpython.com/learning-paths/)
- [Quizzes & Exercises](https://realpython.com/quizzes/)
- [Browse Topics](https://realpython.com/tutorials/all/)
- [Live Courses](https://realpython.com/live/)
- [Books](https://realpython.com/books/)
##### Community
- [Podcast](https://realpython.com/podcasts/rpp/)
- [Newsletter](https://realpython.com/newsletter/)
- [Community Chat](https://realpython.com/community/)
- [Office Hours](https://realpython.com/office-hours/)
- [Learner Stories](https://realpython.com/learner-stories/)
##### Membership
- [Plans & Pricing](https://realpython.com/account/join/)
- [Team Plans](https://realpython.com/account/join-team/)
- [For Business](https://realpython.com/account/join-team/inquiry/)
- [For Schools](https://realpython.com/account/join-team/education-inquiry/)
- [Reviews](https://realpython.com/learner-stories/)
##### Company
- [About Us](https://realpython.com/about/)
- [Team](https://realpython.com/team/)
- [Mission & Values](https://realpython.com/mission/)
- [Editorial Guidelines](https://realpython.com/editorial-guidelines/)
- [Sponsorships](https://realpython.com/sponsorships/)
- [Careers](https://realpython.workable.com/)
- [Press Kit](https://realpython.com/media-kit/)
- [Merch](https://realpython.com/merch)
[Privacy Policy](https://realpython.com/privacy-policy/) â
[Terms of Use](https://realpython.com/terms/) â
[Security](https://realpython.com/security/) â
[Contact](https://realpython.com/contact/)
Happy Pythoning\!
© 2012â2026 DevCademy Media Inc. DBA Real Python. All rights reserved.
REALPYTHONâą is a trademark of DevCademy Media Inc.
[](https://realpython.com/)

You've blocked notifications |
| Readable Markdown | by [Ian Eyre](https://realpython.com/how-to-drop-null-values-in-pandas/#author) Publication date Sep 10, 2025 Reading time estimate 18m [basics](https://realpython.com/tutorials/basics/) [data-science](https://realpython.com/tutorials/data-science/) [python](https://realpython.com/tutorials/python/)
Missing values can derail your analysis. In pandas, you can use the `.dropna()` method to remove rows or columns containing null valuesâin other words, missing dataâso you can work with clean DataFrames. In this tutorial, youâll learn how this methodâs parameters let you control exactly which data gets removed. As youâll see, these parameters give you fine-grained control over how much of your data to clean.
Dealing with null values is essential for keeping datasets clean and avoiding the issues they can cause. Missing entries can lead to misinterpreted column data types, inaccurate conclusions, and errors in calculations. Simply put, nulls can cause havoc if they find their way into your calculations.
**By the end of this tutorial, youâll understand that:**
- You can use **`.dropna()`** to **remove rows and columns** from a pandas DataFrame.
- You can remove rows and columns based on the **content of a subset** of your DataFrame.
- You can remove rows and columns based on the **volume of null values** within your DataFrame.
To get the most out of this tutorial, itâs recommended that you already have a basic understanding of how to create [pandas DataFrames](https://realpython.com/pandas-dataframe/) from files.
Youâll use the Python [REPL](https://realpython.com/ref/glossary/repl/) along with a file named `sales_data_with_missing_values.csv`, which contains several null values youâll deal with during the exercises. Before you start, extract this file from the downloadable materials by clicking the link at the end of this section.
The `sales_data_with_missing_values.csv` file is based on the publicly available and complete [sales data](https://www.kaggle.com/datasets/satyamanidharv/sales-data-presentation-dashboards?resource=download) file from [Kaggle](https://www.kaggle.com/). Understanding the fileâs content isnât essential for this tutorial, but you can explore the Kaggle link above for more details if youâd like.
Youâll also need to install both the pandas and PyArrow libraries to make sure all code examples work in your environment:
- [Windows](https://realpython.com/how-to-drop-null-values-in-pandas/#windows-1)
- [Linux + macOS](https://realpython.com/how-to-drop-null-values-in-pandas/#linux-macos-1)
Itâs time to refine your pandas skills by learning how to handle missing data in a variety of ways.
Youâll find all code examples and the `sales_data_with_missing_values.csv` file in the materials for this tutorial, which you can download by clicking the link below:
***Take the Quiz:*** Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
***
[](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
## How to Drop Rows Containing Null Values With pandas `.dropna()`
Before you start dropping rows, itâs helpful to know what options `.dropna()` gives you. This method supports six **parameters** that let you control exactly whatâs removed:
- **`axis`**: Specifies whether to remove rows or columns containing null values.
- **`thresh`** and **`how`**: Define how many missing values to remove or retain.
- **`subset`**: Limits the removal of null values to specific parts of your DataFrame.
- **`inplace`**: Determines whether the operation modifies the original DataFrame or returns a new copy.
- **`ignore_index`**: Resets the DataFrame index after removing rows.
Donât worry if any of these parameters donât make sense to you just yetâyouâll learn why each is used during this tutorial. Youâll also get the chance to practice your skills.
Before using `.dropna()` to drop rows, you should first find out whether your data contains any [null values](https://realpython.com/null-in-python/):
To make sure all columns appear on your screen, you configure `pd.set_option("display.max_columns", None)`. By passing `None` as the second parameter, you make sure all columns are displayed.
You read the `sales_data_with_missing_values.csv` file into a DataFrame using the [pandas `read_csv()`](https://realpython.com/pandas-read-write-files/#read-a-csv-file) function, then view the data. The order dates are in the `"%d/%m/%Y"` format in the file, so to make sure the `order_date` data is read correctly, you use both the `parse_dates` and `date_format` parameters. The output reveals there are ten rows and six columns of data in your file.
In a real [data analysis](https://realpython.com/python-for-data-analysis/), your DataFrame may be too large to allow you to see everything thatâs missing. To solve this, you use the DataFrameâs [`.isna()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.isna.html) and [`.sum()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.sum.html) methods together:
As you can see, each of your columns is missing data.
When you use `sales_data.isna()`, you create a [Boolean](https://realpython.com/ref/glossary/boolean/) DataFrame the same size as `sales_data`, but with null values replaced with `True` and everything else replaced with `False`. The `.sum()` method counts each `True` and returns it to you as shown.
To remove the rows with null values, you use [`.dropna()`](https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dropna.html):
As you can see, rows with null values are nowhere to be seen.
You might think the rows containing the null values from `sales_data` have been deleted. After all, thatâs what the output shows. However, this isnât true. When you use `sales_data.dropna()`, the results are placed into a new DataFrame, leaving the original unchanged. If you want to retain this second DataFrame, then you need to assign the output from `.dropna()` to a new variable:
Now the `clean_sales_data` DataFrame contains a second copy of the original `sales_data` DataFrame, but without those rows that contained one or more null values. Of course, this is wasteful of memory, so a better option would be to update the original DataFrame. To do this, you pass `inplace=True` to `.dropna()`:
The original `sales_data` DataFrame will no longer contain rows with null values, and any future analysis will occur against this new version.
Youâve now seen the basic use case for `.dropna()`, where you drop rows with at least one missing value. But the method also includes several other parameters worth exploring.
## How to Drop Columns Containing Null Values With pandas `.dropna()`
So far, youâve seen how to drop rows containing missing values, but itâs also possible to drop incomplete columns. You do this using the `axis` parameter. By default, `axis` is set to `0`, or `"index"`, which means it operates on rows of data. If you want to apply it across columns, then you set `axis` to `1` or `"columns"`.
Suppose you want to remove **incomplete columns** containing null values from the original `sales_data`. Hereâs how you do it:
Because every column has at least one missing value, theyâve all been removed, leaving the DataFrame empty except for its index.
So far, youâve taken a fairly aggressive approach by removing entire rows and columns. Next, youâll look at some less destructive alternatives.
## How to Work With a Part of Your Data
Earlier, you used `.dropna()` to remove all null values from your DataFrame. While this is a common use case, you can also remove nulls from specific parts of the DataFrame or based on a certain quantity threshold. Youâll learn how in this section.
### Removing Data Based on Specific Rows or Columns
You can restrict removal of data based on the rows or columns where the null values appear. This is where the `subset` parameter comes in handy.
By passing a **column label** or a sequence of labels to `subset`, you tell `.dropna()` which columns to check for null values and remove their associated rows. Similarly, by passing `subset` an **index position** or a sequence of index positions and setting `axis="columns"`, you remove the column or columns that contain null values at the specified index positions.
For example, suppose you want to remove rows containing null values in either the `discount` or `sale_price columns`. If there are null values in other columns besides `discount` or `sale_price`, then those rows will remain untouched. Hereâs how you do it:
This time, youâve removed four rows. To clarify that youâre removing rows, you explicitly set `axis` to `0`. However, you can omit this argument since `0` is the default value for the `axis` parameter. To restrict your analysis to the two columns you want, you pass the Python list `["discount", "sale_price"]` as the `subset` parameter.
### Removing Data Based on the Quantity of Missing Values
Itâs possible to instruct `.dropna()` to remove rows or columns based on a specified quantity of data. Suppose youâre concerned about the volume of data missing in your DataFrame. Youâre worried about rows with *more than* one missing value. In other words, you want to delete those rows containing at least five pieces of data in their six columns.
To do this, you can set this threshold using the `thresh` parameter:
Rows with indices `1` and `9` have been removed since they contain multiple missing values. By setting `thresh` to `5`, you tell `.dropna()` to keep all rows that contain at least five values. Since there are six columns, all remaining rows have no more than one missing value.
### Removing Empty Rows or Columns
Sometimes you might want to remove only rows or columns that are completely empty, rather than those with just some missing values. You can control this with the `how` parameter.
For example, suppose you want to remove rows where all values are missing:
As you can see, the blank row at index position `9` has been removed. By passing `how="all"` to `.dropna()` and using the default value `axis=0`, you remove rows containing only null values. Alternatively, you could pass `how="any"` to remove rows or columns that have at least one null value. You rarely need to do this, however, because `"any"` is the default value.
### Adding a Finishing Touch: Reset the Index
Finally, you may have noticed that each time you remove a rowâboth here and throughout this tutorialâthe index doesnât update. As a finishing touch, passing `ignore_index=True` will reindex your DataFrame sequentially:
This time, the index starts at `0` and ends at `8`, and there are only nine rows remaining.
To wrap up what youâve covered so far, itâs time to test your new skills.
## Practice Your pandas `.dropna()` Skills
To practice, begin by loading the contents of `grades.csv` into a DataFrame:
The DataFrame shows results for six students in five subjects. In this case, `<NA>` indicates that an exam wasnât taken.
Now, see if you can use `.dropna()` to answer each of the following questions:
1. Use `.dropna()` so that it permanently drops the row in the DataFrame containing only null values. Use this version from this point on.
2. Display the rows for the exams that all students completed.
3. Display any columns with no missing data.
4. Display the exams taken by at least five students.
5. Identify who else completed every exam that both S2 and S4 took.
Youâll find the answers in the downloadable materials below:
## Conclusion
During this tutorial, you learned to use the DataFrameâs `.dropna()` method to remove null values from your DataFrames.
**By using the various parameters, youâve learned how:**
- The `axis` parameter allows you to **remove rows or columns** containing null values.
- The `thresh` and `how` parameters allow you to **define the quantity** of what gets removed.
- The `subset` parameter lets you **restrict the removal** to part of your DataFrame.
- The `inplace` parameter allows you to update either the **original DataFrame or a copy** after deletions.
- The `ignore_index` parameter allows you to **[reset the DataFrame index](https://realpython.com/pandas-reset-index/)** after rows of data have been removed.
Although you now have a solid understanding of `.dropna()`, thereâs still lots to explore.
Review what youâve learned here to identify which techniques best fit your needs for handling missing values. You may also want to apply these skills to the `.dropna()` methods for pandas Series and Index objects. Doing so is a great way to continue your learning journey.
***Take the Quiz:*** Test your knowledge with our interactive âHow to Drop Null Values in pandasâ quiz. Youâll receive a score upon completion to help you track your learning progress:
***
[](https://realpython.com/quizzes/how-to-drop-null-values-in-pandas/)
## Frequently Asked Questions
Now that you have some experience with dropping null values in pandas, you can use the questions and answers below to check your understanding and recap what youâve learned.
These FAQs are related to the most important concepts youâve covered in this tutorial. Click the *Show/Hide* toggle beside each question to reveal the answer.
You use the `.dropna()` method to remove rows or columns with null values from your DataFrame.
You remove empty values by using the `.dropna()` method, which lets you drop rows or columns containing null values.
You use the `thresh` parameter to specify the minimum number of non-null values a row or column must have to avoid being dropped.
You set the `axis` parameter to `1` or `"columns"` in the `.dropna()` method to drop columns containing null values.
When you set `inplace=True`, you update the original DataFrame directly, removing rows or columns with null values without creating a new DataFrame. |
| Shard | 71 (laksa) |
| Root Hash | 13351397557425671 |
| Unparsed URL | com,realpython!/how-to-drop-null-values-in-pandas/ s443 |