ℹ️ 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.1 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://sparkbyexamples.com/pandas/remove-nan-from-pandas-series/ |
| Last Crawled | 2026-04-05 08:39:30 (3 days ago) |
| First Indexed | 2022-09-20 17:30:07 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Remove NaN From Pandas Series - Spark By {Examples} |
| Meta Description | In pandas, you can use the Series.dropna() function to remove NaN (Not a Number) values from a Series. It returns new series with the same values as the |
| Meta Canonical | null |
| Boilerpipe Text | In pandas, you can use the
<code>Series.dropna()
function to remove NaN (Not a Number) values from a Series. It returns new series with the same values as the original but without any NaN values. In this article, I will explain how to remove NaN from Series in Pandas by using
dropna()
and other methods with examples.
Advertisements
Key Points –
Use Pandas’ built-in methods to efficiently identify and eliminate NaN values from Series.
Use Pandas functions like
isnull()
or
notnull()
to locate NaN values.
Use the
dropna()
method to remove
NaN
values from a Pandas Series.
dropna()
returns a new Series with
NaN
entries excluded.
Use methods like
dropna()
to remove NaN values from the Series.
The original Series remains unchanged unless
inplace=True
is specified.
Removing
NaN
can affect the Series index unless the index is reset.
It works only on
NaN
values, not on other placeholders like empty strings or zeros.
If you are in a hurry, below are some quick examples of how to remove NaN from the pandas series.
# Quick examples of remove NaN from series
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
Syntax of Series.dropna() Function
Following is the syntax of
Series.dropna()
function.
# Syntax of Series.dropna() function
Series.dropna(axis=0, inplace=False, how=None)
Parameter of dropna()
Following are the parameters of the dropna().
axis
– {0 or ‘index’} by default Value 0: There is only one axis to drop values from.
inplace
– boolean, default Value: False: If True, do an operation in place and return None.
how
– str, this optional parameter: Not in use.
Return Value
This function returns the pandas Series without NaN values.
Create Pandas Series
Now, let’s create pandas series using a list. Note that NaN in pandas and represent by using
NumPy
np.nan.
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print("Create series:\n",ser)
Yields below output.
Use dropna() Method to Remove NaN Values From Series
Using
dropna()
method we can remove the NaN values from the series. Let’s use
Series.dropna()
method to remove NaN (missing) values from the original Series to get a new series. This method returns a new Series after removing all NAN values.
# Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
Yields below output.
# Output:
0 Java
1 Spark
3 PySpark
5 Pandas
6 NumPy
8 Python
dtype: object
Use isnull() Method to Remove NaN Values From Series
We can also use
Series.isnull()
on the original Series to get a new Series with only boolean values and the same dimensions as the original. The boolean Series contains True if the value in the original is NaN and False otherwise for each element and use this Series on the original series to remove all NaN values.
# Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
Yields the same output as above.
Complete Example For Remove NaN From Series
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print(ser)
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
FAQ on Remove NaN From Pandas Series?
How do I check for NaN values in a pandas Series?
You can check for NaN values in a pandas Series using the
isna()
or
isnull()
method. For example, the
nan_mask
will be a boolean Series where each element is
True
if the corresponding element in the original Series is NaN and
False
otherwise.
How can I remove NaN values from a pandas Series?
You can remove NaN values from a pandas Series using the
dropna()
method. For example,
data.dropna()
returns a new Series (
data_without_nan
) where NaN values have been removed. If you want to modify the original Series in place, you can use the
inplace
parameter
Can I remove NaN values in place without creating a new Series?
You can remove NaN values from a pandas Series in place without creating a new Series by using the
dropna()
method with the
inplace
parameter set to
True
.
Is there an alternative way to remove NaN values using boolean indexing?
An alternative way to remove NaN values from a pandas Series is to use boolean indexing. You can use the
notna()
method to create a boolean mask and then use that mask to filter out the NaN values.
Are there any other options to handle NaN values in pandas?
You can use methods like
fillna()
to fill NaN values with a specific value or strategy.
Conclusion
In this article, I have explained how to remove NaN values from Series in Pandas by using
Series.dropna()
, and
Series.isnull()
functions with examples.
Happy Learning !!
Related Articles
Pandas DataFrame isna() function.
Pandas Replace Values based on Condition
Pandas Replace Column value in DataFrame
Pandas Series.fillna() function explained
Count NaN Values in Pandas DataFrame
Pandas Drop Columns with NaN or None Values
Pandas – Check Any Value is NaN in DataFrame
Pandas DataFrame.fillna() function explained
Create Pandas DataFrame With Working Examples
Get Column Average or Mean in Pandas DataFrame
Select Multiple Columns in Pandas DataFrame
Drop Rows with NaN Values in Pandas DataFrame
Pandas Replace Blank/Empty String with NaN values
Pandas – Replace NaN Values with Zero in a Column
Different Ways to Upgrade PIP Latest or to a Specific Version
References
https://pandas.pydata.org/docs/reference/api/pandas.Series.dropna.html |
| Markdown | [Skip to content](https://sparkbyexamples.com/pandas/remove-nan-from-pandas-series/#main)
- [Home](https://sparkbyexamples.com/)
- [About](https://sparkbyexamples.com/about-sparkbyexamples/)
\| \*\*\* Please
[**Subscribe**](https://sparkbyexamples.com/membership-account/membership-levels)
for Ad Free & Premium Content \*\*\*
[Spark By {Examples}](https://sparkbyexamples.com/)
- [Connect](https://topmate.io/naveennel)
- [\|](https://sparkbyexamples.com/pandas/remove-nan-from-pandas-series/)
- [Join for Ad Free](https://sparkbyexamples.com/membership-account/membership-levels/)
- [Courses](https://sparkbyexamples.thinkific.com/courses/)
- [Mastering Spark with Scala](https://sparkbyexamples.thinkific.com/courses/mastering-apache-spark-tutorial)
- [Mastering PySpark](https://sparkbyexamples.thinkific.com/courses/pyspark-tutorial)
- [Spark](https://sparkbyexamples.com/ "Apache Spark")
- [Spark Introduction](https://sparkbyexamples.com/)
- [Spark RDD Tutorial](https://sparkbyexamples.com/spark-rdd-tutorial/)
- [Spark SQL Functions](https://sparkbyexamples.com/spark/spark-sql-functions/)
- [What’s New in Spark 3.0?](https://sparkbyexamples.com/category/spark/spark-3-0/)
- [Spark Streaming](https://sparkbyexamples.com/apache-spark-streaming-tutorial/)
- [Apache Spark on AWS](https://sparkbyexamples.com/apache-spark-on-amazon-web-services/)
- [Apache Spark Interview Questions](https://sparkbyexamples.com/interview-questions/apache-spark-interview-questions/)
- [PySpark](https://sparkbyexamples.com/pyspark-tutorial/)
- [Pandas](https://sparkbyexamples.com/python-pandas-tutorial-for-beginners/)
- [R](https://sparkbyexamples.com/r-tutorial-with-examples/)
- [R Programming](https://sparkbyexamples.com/r-tutorial-with-examples/)
- [R Data Frame](https://sparkbyexamples.com/r-programming/r-data-frames/)
- [R dplyr Tutorial](https://sparkbyexamples.com/r-programming/r-dplyr-tutorial-learn-with-examples/)
- [R Vector](https://sparkbyexamples.com/r-programming/vector-in-r/)
- [Tutorials](https://sparkbyexamples.com/)
- [Hive](https://sparkbyexamples.com/apache-hive-tutorial/)
- [Snowflake](https://sparkbyexamples.com/snowflake-data-warehouse-database-tutorials/)
- [H2O.ai](https://sparkbyexamples.com/h2o-sparkling-water-tutorial-beginners/)
- [AWS](https://sparkbyexamples.com/apache-spark-on-amazon-web-services/)
- [Apache Kafka Tutorials with Examples](https://sparkbyexamples.com/apache-kafka-tutorials-with-examples/)
- [Apache Hadoop Tutorials with Examples :](https://sparkbyexamples.com/apache-hadoop-tutorials-with-examples/)
- [NumPy](https://sparkbyexamples.com/python-numpy-tutorial-for-beginners/)
- [Apache HBase](https://sparkbyexamples.com/apache-hbase-tutorial/)
- [Apache Cassandra Tutorials with Examples](https://sparkbyexamples.com/apache-cassandra-tutorials-with-examples/)
- [H2O Sparkling Water](https://sparkbyexamples.com/h2o-sparkling-water-tutorial-beginners/)
- [Pricing](https://sparkbyexamples.com/membership-account/membership-levels/)
- [Log In](https://sparkbyexamples.com/login/)
- [Toggle website search](https://sparkbyexamples.com/)
[Menu Close](https://sparkbyexamples.com/#mobile-menu-toggle)
- [Courses](https://sparkbyexamples.thinkific.com/courses/)
- [Mastering Spark with Scala](https://sparkbyexamples.thinkific.com/courses/mastering-apache-spark-tutorial)
- [Mastering PySpark](https://sparkbyexamples.thinkific.com/courses/pyspark-tutorial)
- [Spark](https://sparkbyexamples.com/ "Apache Spark")
- [Spark Introduction](https://sparkbyexamples.com/)
- [Spark RDD Tutorial](https://sparkbyexamples.com/spark-rdd-tutorial/)
- [Spark SQL Functions](https://sparkbyexamples.com/spark/spark-sql-functions/)
- [What’s New in Spark 3.0?](https://sparkbyexamples.com/category/spark/spark-3-0/)
- [Spark Streaming](https://sparkbyexamples.com/apache-spark-streaming-tutorial/)
- [Apache Spark on AWS](https://sparkbyexamples.com/apache-spark-on-amazon-web-services/)
- [Apache Spark Interview Questions](https://sparkbyexamples.com/interview-questions/apache-spark-interview-questions/)
- [PySpark](https://sparkbyexamples.com/pyspark-tutorial/)
- [Pandas](https://sparkbyexamples.com/python-pandas-tutorial-for-beginners/)
- [R](https://sparkbyexamples.com/r-tutorial-with-examples/)
- [R Programming](https://sparkbyexamples.com/r-tutorial-with-examples/)
- [R Data Frame](https://sparkbyexamples.com/r-programming/r-data-frames/)
- [R dplyr Tutorial](https://sparkbyexamples.com/r-programming/r-dplyr-tutorial-learn-with-examples/)
- [R Vector](https://sparkbyexamples.com/r-programming/vector-in-r/)
- [Tutorials](https://sparkbyexamples.com/)
- [Hive](https://sparkbyexamples.com/apache-hive-tutorial/)
- [Snowflake](https://sparkbyexamples.com/snowflake-data-warehouse-database-tutorials/)
- [H2O.ai](https://sparkbyexamples.com/h2o-sparkling-water-tutorial-beginners/)
- [AWS](https://sparkbyexamples.com/apache-spark-on-amazon-web-services/)
- [Apache Kafka Tutorials with Examples](https://sparkbyexamples.com/apache-kafka-tutorials-with-examples/)
- [Apache Hadoop Tutorials with Examples :](https://sparkbyexamples.com/apache-hadoop-tutorials-with-examples/)
- [NumPy](https://sparkbyexamples.com/python-numpy-tutorial-for-beginners/)
- [Apache HBase](https://sparkbyexamples.com/apache-hbase-tutorial/)
- [Apache Cassandra Tutorials with Examples](https://sparkbyexamples.com/apache-cassandra-tutorials-with-examples/)
- [H2O Sparkling Water](https://sparkbyexamples.com/h2o-sparkling-water-tutorial-beginners/)
- [Pricing](https://sparkbyexamples.com/membership-account/membership-levels/)
- [Log In](https://sparkbyexamples.com/login/)
- [Toggle website search](https://sparkbyexamples.com/)
- [Home](https://sparkbyexamples.com/)
- [About](https://sparkbyexamples.com/about-sparkbyexamples/)
# Remove NaN From Pandas Series
[Home](https://sparkbyexamples.com/) » [Pandas](https://sparkbyexamples.com/category/pandas/) » Remove NaN From Pandas Series
- Post author:[Malli](https://sparkbyexamples.com/author/mallik481/ "Posts by Malli")
- Post category:[Pandas](https://sparkbyexamples.com/category/pandas/)
- Post last modified:June 23, 2025
- Reading time:14 mins read

In pandas, you can use the `<code>Series.dropna()` function to remove NaN (Not a Number) values from a Series. It returns new series with the same values as the original but without any NaN values. In this article, I will explain how to remove NaN from Series in Pandas by using `dropna()` and other methods with examples.
Advertisements
**Key Points –**
- Use Pandas’ built-in methods to efficiently identify and eliminate NaN values from Series.
- Use Pandas functions like `isnull()` or `notnull()` to locate NaN values.
- Use the `dropna()` method to remove `NaN` values from a Pandas Series.
- `dropna()` returns a new Series with `NaN` entries excluded.
- Use methods like `dropna()` to remove NaN values from the Series.
- The original Series remains unchanged unless `inplace=True` is specified.
- Removing `NaN` can affect the Series index unless the index is reset.
- It works only on `NaN` values, not on other placeholders like empty strings or zeros.
## Quick Examples of Remove NaN From Series
If you are in a hurry, below are some quick examples of how to remove NaN from the pandas series.
```
# Quick examples of remove NaN from series
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
```
## Syntax of Series.dropna() Function
Following is the syntax of `Series.dropna()` function.
```
# Syntax of Series.dropna() function
Series.dropna(axis=0, inplace=False, how=None)
```
### Parameter of dropna()
Following are the parameters of the dropna().
- `axis` – {0 or ‘index’} by default Value 0: There is only one axis to drop values from.
- `inplace` – boolean, default Value: False: If True, do an operation in place and return None.
- `how` – str, this optional parameter: Not in use.
### Return Value
This function returns the pandas Series without NaN values.
## Create Pandas Series
Now, let’s create pandas series using a list. Note that NaN in pandas and represent by using [NumPy](https://sparkbyexamples.com/python-numpy-tutorial-for-beginners/) np.nan.
```
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print("Create series:\n",ser)
```
Yields below output.

## Use dropna() Method to Remove NaN Values From Series
Using` dropna()` method we can remove the NaN values from the series. Let’s use `Series.dropna()` method to remove NaN (missing) values from the original Series to get a new series. This method returns a new Series after removing all NAN values.
```
# Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
```
Yields below output.
```
# Output:
0 Java
1 Spark
3 PySpark
5 Pandas
6 NumPy
8 Python
dtype: object
```
## Use isnull() Method to Remove NaN Values From Series
We can also use `Series.isnull()` on the original Series to get a new Series with only boolean values and the same dimensions as the original. The boolean Series contains True if the value in the original is NaN and False otherwise for each element and use this Series on the original series to remove all NaN values.
```
# Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
```
Yields the same output as above.
## Complete Example For Remove NaN From Series
```
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print(ser)
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
```
## FAQ on Remove NaN From Pandas Series?
**How do I check for NaN values in a pandas Series?**
You can check for NaN values in a pandas Series using the `isna()` or `isnull()` method. For example, the `nan_mask` will be a boolean Series where each element is `True` if the corresponding element in the original Series is NaN and `False` otherwise.
**How can I remove NaN values from a pandas Series?**
You can remove NaN values from a pandas Series using the `dropna()` method. For example, `data.dropna()` returns a new Series (`data_without_nan`) where NaN values have been removed. If you want to modify the original Series in place, you can use the `inplace` parameter
**Can I remove NaN values in place without creating a new Series?**
You can remove NaN values from a pandas Series in place without creating a new Series by using the `dropna()` method with the `inplace` parameter set to `True`.
**Is there an alternative way to remove NaN values using boolean indexing?**
An alternative way to remove NaN values from a pandas Series is to use boolean indexing. You can use the `notna()` method to create a boolean mask and then use that mask to filter out the NaN values.
**Are there any other options to handle NaN values in pandas?**
You can use methods like `fillna()` to fill NaN values with a specific value or strategy.
## Conclusion
In this article, I have explained how to remove NaN values from Series in Pandas by using `Series.dropna()`, and `Series.isnull()` functions with examples.
Happy Learning !\!
## Related Articles
- [Pandas DataFrame isna() function.](https://sparkbyexamples.com/pandas/pandas-dataframe-isna-function/)
- [Pandas Replace Values based on Condition](https://sparkbyexamples.com/pandas/pandas-replace-values-based-on-condition/)
- [Pandas Replace Column value in DataFrame](https://sparkbyexamples.com/pandas/pandas-replace-column-value-in-dataframe/)
- [Pandas Series.fillna() function explained](https://sparkbyexamples.com/pandas/pandas-series-fillna-function/)
- [Count NaN Values in Pandas DataFrame](https://sparkbyexamples.com/pandas/count-nan-values-in-pandas/)
- [Pandas Drop Columns with NaN or None Values](https://sparkbyexamples.com/pandas/pandas-drop-columns-with-nan-none-values/)
- [Pandas – Check Any Value is NaN in DataFrame](https://sparkbyexamples.com/pandas/pandas-check-if-any-value-is-nan-in-a-dataframe/)
- [Pandas DataFrame.fillna() function explained](https://sparkbyexamples.com/pandas/pandas-dataframe-fillna-explained/)
- [Create Pandas DataFrame With Working Examples](https://sparkbyexamples.com/pandas/pandas-create-dataframe-with-examples)
- [Get Column Average or Mean in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-get-column-average-mean)
- [Select Multiple Columns in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-select-multiple-columns-in-dataframe/)
- [Drop Rows with NaN Values in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-how-to-drop-rows-with-nan-values-in-dataframe/)
- [Pandas Replace Blank/Empty String with NaN values](https://sparkbyexamples.com/pandas/pandas-replace-blank-values-with-nan/)
- [Pandas – Replace NaN Values with Zero in a Column](https://sparkbyexamples.com/pandas/pandas-replace-nan-values-by-zero-in-a-column/)
- [Different Ways to Upgrade PIP Latest or to a Specific Version](https://sparkbyexamples.com/python/upgrade-pip-latest-or-specific-version/)
## References
- <https://pandas.pydata.org/docs/reference/api/pandas.Series.dropna.html>
Tags: [pandas Series](https://sparkbyexamples.com/tag/pandas-series/)
#### LOGIN for Tutorial Menu
- [Log In](https://sparkbyexamples.com/login/)
## Top Tutorials
- [Apache Spark Tutorial](https://sparkbyexamples.com/)
- [PySpark Tutorial](https://sparkbyexamples.com/pyspark-tutorial/)
- [Python Pandas Tutorial](https://sparkbyexamples.com/python-pandas-tutorial-for-beginners/)
- [R Programming Tutorial](https://sparkbyexamples.com/r-tutorial-with-examples/)
- [Python NumPy Tutorial](https://sparkbyexamples.com/python-numpy-tutorial-for-beginners/)
- [Apache Hive Tutorial](https://sparkbyexamples.com/apache-hive-tutorial/)
- [Apache HBase Tutorial](https://sparkbyexamples.com/apache-hbase-tutorial/)
- [Apache Cassandra Tutorial](https://sparkbyexamples.com/apache-cassandra-tutorials-with-examples/)
- [Apache Kafka Tutorial](https://sparkbyexamples.com/apache-kafka-tutorials-with-examples/)
- [Snowflake Data Warehouse Tutorial](https://sparkbyexamples.com/snowflake-data-warehouse-database-tutorials/)
- [H2O Sparkling Water Tutorial](https://sparkbyexamples.com/h2o-sparkling-water-tutorial-beginners/)
## Categories
- [Apache Spark](https://sparkbyexamples.com/category/spark/)
- [PySpark](https://sparkbyexamples.com/category/pyspark/)
- [Pandas](https://sparkbyexamples.com/category/pandas/)
- [R Programming](https://sparkbyexamples.com/category/r-programming/)
- [Snowflake Database](https://sparkbyexamples.com/category/snowflake/)
- [NumPy](https://sparkbyexamples.com/category/numpy/)
- [Apache Hive](https://sparkbyexamples.com/category/apache-hive/)
- [Apache HBase](https://sparkbyexamples.com/category/hbase/)
- [Apache Kafka](https://sparkbyexamples.com/category/kafka/)
- [Apache Cassandra](https://sparkbyexamples.com/category/cassandra/)
- [H2O Sparkling Water](https://sparkbyexamples.com/category/h2o-sparkling-water/)
## Legal
- [SparkByExamples.com – Privacy Policy](https://sparkbyexamples.com/privacy-policy/)
- [Refund Policy](https://sparkbyexamples.com/refund-policy/)
- [Terms of Use](https://sparkbyexamples.com/terms-of-use/)

- Opens in a new tab
- Opens in a new tab
- Opens in a new tab
- Opens in a new tab
- Opens in a new tab
Copyright 2024 www.SparkByExamples.com. All rights reserved. |
| Readable Markdown | 
In pandas, you can use the `<code>Series.dropna()` function to remove NaN (Not a Number) values from a Series. It returns new series with the same values as the original but without any NaN values. In this article, I will explain how to remove NaN from Series in Pandas by using `dropna()` and other methods with examples.
Advertisements
**Key Points –**
- Use Pandas’ built-in methods to efficiently identify and eliminate NaN values from Series.
- Use Pandas functions like `isnull()` or `notnull()` to locate NaN values.
- Use the `dropna()` method to remove `NaN` values from a Pandas Series.
- `dropna()` returns a new Series with `NaN` entries excluded.
- Use methods like `dropna()` to remove NaN values from the Series.
- The original Series remains unchanged unless `inplace=True` is specified.
- Removing `NaN` can affect the Series index unless the index is reset.
- It works only on `NaN` values, not on other placeholders like empty strings or zeros.
If you are in a hurry, below are some quick examples of how to remove NaN from the pandas series.
```
# Quick examples of remove NaN from series
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
```
## Syntax of Series.dropna() Function
Following is the syntax of `Series.dropna()` function.
```
# Syntax of Series.dropna() function
Series.dropna(axis=0, inplace=False, how=None)
```
### Parameter of dropna()
Following are the parameters of the dropna().
- `axis` – {0 or ‘index’} by default Value 0: There is only one axis to drop values from.
- `inplace` – boolean, default Value: False: If True, do an operation in place and return None.
- `how` – str, this optional parameter: Not in use.
### Return Value
This function returns the pandas Series without NaN values.
## Create Pandas Series
Now, let’s create pandas series using a list. Note that NaN in pandas and represent by using [NumPy](https://sparkbyexamples.com/python-numpy-tutorial-for-beginners/) np.nan.
```
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print("Create series:\n",ser)
```
Yields below output.

## Use dropna() Method to Remove NaN Values From Series
Using` dropna()` method we can remove the NaN values from the series. Let’s use `Series.dropna()` method to remove NaN (missing) values from the original Series to get a new series. This method returns a new Series after removing all NAN values.
```
# Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
```
Yields below output.
```
# Output:
0 Java
1 Spark
3 PySpark
5 Pandas
6 NumPy
8 Python
dtype: object
```
## Use isnull() Method to Remove NaN Values From Series
We can also use `Series.isnull()` on the original Series to get a new Series with only boolean values and the same dimensions as the original. The boolean Series contains True if the value in the original is NaN and False otherwise for each element and use this Series on the original series to remove all NaN values.
```
# Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
```
Yields the same output as above.
## Complete Example For Remove NaN From Series
```
import pandas as pd
import numpy as np
# Create the Series
ser = pd.Series(['Java', 'Spark', np.nan, 'PySpark', np.nan,'Pandas','NumPy', np.nan,'Python'])
print(ser)
# Example 1: Use dropna()
# To remove nan values from a pandas series
ser2 = ser.dropna()
print(ser2)
# Example 2: Use isnull()
# To remove nan values from a pandas series
ser2 = ser[~ser.isnull()]
print(ser2)
```
## FAQ on Remove NaN From Pandas Series?
**How do I check for NaN values in a pandas Series?**
You can check for NaN values in a pandas Series using the `isna()` or `isnull()` method. For example, the `nan_mask` will be a boolean Series where each element is `True` if the corresponding element in the original Series is NaN and `False` otherwise.
**How can I remove NaN values from a pandas Series?**
You can remove NaN values from a pandas Series using the `dropna()` method. For example, `data.dropna()` returns a new Series (`data_without_nan`) where NaN values have been removed. If you want to modify the original Series in place, you can use the `inplace` parameter
**Can I remove NaN values in place without creating a new Series?**
You can remove NaN values from a pandas Series in place without creating a new Series by using the `dropna()` method with the `inplace` parameter set to `True`.
**Is there an alternative way to remove NaN values using boolean indexing?**
An alternative way to remove NaN values from a pandas Series is to use boolean indexing. You can use the `notna()` method to create a boolean mask and then use that mask to filter out the NaN values.
**Are there any other options to handle NaN values in pandas?**
You can use methods like `fillna()` to fill NaN values with a specific value or strategy.
## Conclusion
In this article, I have explained how to remove NaN values from Series in Pandas by using `Series.dropna()`, and `Series.isnull()` functions with examples.
Happy Learning !\!
## Related Articles
- [Pandas DataFrame isna() function.](https://sparkbyexamples.com/pandas/pandas-dataframe-isna-function/)
- [Pandas Replace Values based on Condition](https://sparkbyexamples.com/pandas/pandas-replace-values-based-on-condition/)
- [Pandas Replace Column value in DataFrame](https://sparkbyexamples.com/pandas/pandas-replace-column-value-in-dataframe/)
- [Pandas Series.fillna() function explained](https://sparkbyexamples.com/pandas/pandas-series-fillna-function/)
- [Count NaN Values in Pandas DataFrame](https://sparkbyexamples.com/pandas/count-nan-values-in-pandas/)
- [Pandas Drop Columns with NaN or None Values](https://sparkbyexamples.com/pandas/pandas-drop-columns-with-nan-none-values/)
- [Pandas – Check Any Value is NaN in DataFrame](https://sparkbyexamples.com/pandas/pandas-check-if-any-value-is-nan-in-a-dataframe/)
- [Pandas DataFrame.fillna() function explained](https://sparkbyexamples.com/pandas/pandas-dataframe-fillna-explained/)
- [Create Pandas DataFrame With Working Examples](https://sparkbyexamples.com/pandas/pandas-create-dataframe-with-examples)
- [Get Column Average or Mean in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-get-column-average-mean)
- [Select Multiple Columns in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-select-multiple-columns-in-dataframe/)
- [Drop Rows with NaN Values in Pandas DataFrame](https://sparkbyexamples.com/pandas/pandas-how-to-drop-rows-with-nan-values-in-dataframe/)
- [Pandas Replace Blank/Empty String with NaN values](https://sparkbyexamples.com/pandas/pandas-replace-blank-values-with-nan/)
- [Pandas – Replace NaN Values with Zero in a Column](https://sparkbyexamples.com/pandas/pandas-replace-nan-values-by-zero-in-a-column/)
- [Different Ways to Upgrade PIP Latest or to a Specific Version](https://sparkbyexamples.com/python/upgrade-pip-latest-or-specific-version/)
## References
- <https://pandas.pydata.org/docs/reference/api/pandas.Series.dropna.html> |
| Shard | 46 (laksa) |
| Root Hash | 13197168827745396246 |
| Unparsed URL | com,sparkbyexamples!/pandas/remove-nan-from-pandas-series/ s443 |