You can use DataFrame.fillna or Series.fillna which will replace the Python object None, not the string 'None'.

import pandas as pd
import numpy as np

For dataframe:

df = df.fillna(value=np.nan)

For column or series:

df.mycol.fillna(value=np.nan, inplace=True)
Answer from Guillaume Jacquenot on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.fillna.html
pandas.DataFrame.fillna — pandas 3.0.2 documentation
For non-object dtype, value=None will use the NA value of the dtype. See more details in the Filling missing data section. ... >>> df = pd.DataFrame( ... [ ... [np.nan, 2, np.nan, 0], ... [3, 4, np.nan, 1], ... [np.nan, np.nan, np.nan, np.nan], ... [np.nan, 3, np.nan, 4], ... ], ... columns=list("ABCD"), ... ) >>> df A B C D 0 NaN 2.0 NaN 0.0 1 3.0 4.0 NaN 1.0 2 NaN NaN NaN NaN 3 NaN 3.0 NaN 4.0 · Replace all NaN elements with 0s.
Discussions

Problem with DataFrame.replace using None
The expected output would be all ... be replaced with either None or NaN, or at least a warning message alerting for this behaviour. ... commit: None python: 3.6.8.final.0 python-bits: 64 OS: Darwin OS-release: 18.5.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8 · pandas: 0.24.1 pytest: ... More on github.com
🌐 github.com
7
April 11, 2019
python - How to replace 0 with None in a pandas column? - Stack Overflow
This seems to be a trivial question but for some reason, I cannot get the code to work. Firstly for the context, column[B] is an object data typed column with 0, "A", "B". A B 0... More on stackoverflow.com
🌐 stackoverflow.com
python - Rename "None" value in Pandas - Stack Overflow
This is probably super simple but I just can not find the answer. I import data using GeoPandas from a shape file. Turn that into pandas DataFrame. I have a object field with three letter codes and... More on stackoverflow.com
🌐 stackoverflow.com
May 22, 2017
python - Pandas - How to replace string with zero values in a DataFrame series? - Stack Overflow
I'm importing some csv data into a Pandas DataFrame (in Python). One series is meant to be all numerical values. However, it also contains some spurious "$-" elements represented as strings. These ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Reddit
reddit.com › r/learnpython › issue replacing 'none' with df.fillna()
r/learnpython on Reddit: Issue replacing 'None' with df.fillna()
July 10, 2022 -

Hey All,

I am using the below code to export Jira issues. Not all of my issues have all the custom fields I am trying to export so they end up being 'None'. I would like to replace the 'None' with an empty string. I am trying to use pandas df.fillna but it's not doing what I thought it would. In spite of using fillna, my output is unchanged and still contains 'None' values.

What am I doing wrong?

Thanks!

Code:

# Search all issues, and time execution
jira_issues = jira.search_issues(jql,maxResults=50)

# Converge JSON to Pandas DataFrame
for issue in jira_issues:
    try:
        issue_fields = pd.DataFrame({
            'id':                       [issue.id],
            'Due date':                 str(issue.fields.duedate),
            'Actual Start Date':          str(issue.fields.customfield_10055),
            'Actual Completion Date':     str(issue.fields.customfield_10057)
        })
    except AttributeError:
        pass
    issues = pd.concat([issues,issue_fields])

issues.fillna("",inplace=True)
print(issues)

Output:

0  79906        None              None                   None
0  79904  2022-07-07        2022-05-18             2022-05-25
0  79903  2022-04-13        2022-04-22             2022-04-22
0  79902  2022-06-15        2022-06-04             2022-06-04
0  79901        None              None                   None
0  79900        None        2022-06-14                   None
0  79899  2022-05-06        2022-05-02             2022-05-06
0  79897        None              None                   None
0  79896        None              None                   None

Checking column types using dtypes:

id                        object
Due date                  object
Actual Start Date         object
Actual Completion Date    object
dtype: object
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas replace nan values with zero in a column
Pandas Replace NaN Values with Zero in a Column - Spark By {Examples}
June 26, 2025 - You can use the pandas.DataFrame.fillna() or pandas.DataFrame.replace() methods to replace all NaN or None values in an entire DataFrame with zeros (0).
🌐
GeeksforGeeks
geeksforgeeks.org › python › replace-nan-values-with-zeros-in-pandas-dataframe
Replace NaN Values with Zeros in Pandas DataFrame - GeeksforGeeks
Syntax to replace NaN values with zeros of a single column in Pandas dataframe using fillna() function is as follows: Syntax: df['DataFrame Column'] = df['DataFrame Column'].fillna(0)
Published   July 15, 2025
🌐
GitHub
github.com › pandas-dev › pandas › issues › 26050
Problem with DataFrame.replace using None · Issue #26050 · pandas-dev/pandas
April 11, 2019 - Code Sample, a copy-pastable example if possible import pandas as pd import numpy as np ar = np.random.normal(size=[100,10]) df = pd.DataFrame(ar).astype(str) df.replace('0',None) Problem description Every time I run something similar to...
Author   josegcpa
Find elsewhere
🌐
Erikrood
erikrood.com › Python_References › replace_nan_zero_final.html
Replace all NaN values with 0's in a column of Pandas dataframe
Practice interviewing with a few questions per week. import pandas as pd import numpy as np · raw_data = {'name': ['Willard Morris', 'Al Jennings', 'Omar Mullins', 'Spencer McDaniel'], 'age': [20, 19, 22, 21], 'favorite_color': ['blue', 'red', 'yellow', "green"], 'grade': [88, 92, 95, 70]} df = pd.DataFrame(raw_data, index = ['Willard Morris', 'Al Jennings', 'Omar Mullins', 'Spencer McDaniel']) df · #First, we have to create the NaN values df = df.replace(20,np.NaN) df = df.replace(70,np.NaN) df ·
🌐
GeeksforGeeks
geeksforgeeks.org › replace-all-the-nan-values-with-zeros-in-a-column-of-a-pandas-dataframe
Replace all the NaN values with Zero's in a column of a Pandas dataframe - GeeksforGeeks
August 25, 2021 - Object with null values filled or None if inplace=True. Code: Create a Dataframe. Python3 · # Import Pandas Library import pandas as pd # Import Numpy Library import numpy as np # Create a DataFrame df = pd.DataFrame([[np.nan, 2, 3, np.nan], [3, 4, np.nan, 1], [1, np.nan, np.nan, 5], [np.nan, 3, np.nan, 4]]) # Show the DataFrame print(df) Output: Code: Replace all the NaN values with Zero's · Python3 · # Filling null values # with 0 df.fillna(value = 0, inplace = True) # Show the DataFrame print(df) Output: This method is used to replace null or null values with a specific value.
🌐
JanBask Training
janbasktraining.com › community › data-science › pandas-replace-nan-with-none
Replace None with NaN in pandas dataframe | JanBask Training Community
July 8, 2021 - Use DataFrame.fillna or Series.fillna which will help in replacing the Python object None, not the string 'None'. import pandas as pd · For dataframe: df.fillna(value=pd.np.nan, inplace=True) For column or series: df.mycol.fillna(value=pd.np.nan, inplace=True) Upvote 0 ·
🌐
Statology
statology.org › home › pandas: how to replace zero with nan
Pandas: How to Replace Zero with NaN
October 3, 2022 - import numpy as np #replace all zeros with NaN values df.replace(0, np.nan, inplace=True) #view updated DataFrame print(df) points assists rebounds 0 25.0 5.0 11.0 1 NaN NaN 8.0 2 15.0 7.0 10.0 3 14.0 NaN 6.0 4 19.0 12.0 6.0 5 23.0 9.0 NaN 6 25.0 9.0 9.0 7 29.0 4.0 NaN · Notice that each zero in every column of the DataFrame has been replaced with NaN. Note: We must use the argument inplace=True or else the changes won’t be made to the original DataFrame. Related: How to Replace NaN Values with Zero in Pandas
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-pandas-dataframe-fillna-to-replace-null-values-in-dataframe
Pandas DataFrame.fillna() | Python - GeeksforGeeks
February 23, 2026 - Example: This example creates a DataFrame with missing values and replaces all NaN values with 0 using fillna(). Python · import pandas as pd df = pd.DataFrame({"A": [1, None, 3], "B": [None, 5, 6]}) r = df.fillna(0) print(r) Output · A B 0 1.0 0.0 1 0.0 5.0 2 3.0 6.0 ·
Top answer
1 of 3
12

Updated answer, April 2025:

pd.to_numeric can convert arguments to a numeric type. The option errors='coerce' sets things to NaN. However, it can only work on 1D objects (i.e. scalar, list, tuple, 1-d array, or Series). Therefore, to use it on a DataFrame, we need to use df.apply to convert each column individually. Note that any **kwargs given to apply will be passed onto the function, so we can still set errors='coerce'.

Using pd.to_numeric along with df.apply will set any strings to NaN. If we want to convert those to 0 values, we can then use .fillna(0) on the resulting DataFrame.

For example (and note this also works with the strings suggested by the original question "$-" and "($24)"):

import pandas as pd

df = pd.DataFrame({
    'a': (1, 'sd', 1),
    'b': (2., 2., 'fg'),
    'c': (4, "$-", "($24)")
    })

print(df)

#     a    b  c
# 0   1  2.0  4
# 1  sd  2.0     $-
# 2   1   fg  ($24)

df = df.apply(pd.to_numeric, errors='coerce').fillna(0)

print(df)

#      a    b  c
# 0  1.0  2.0  4.0
# 1  0.0  2.0  0.0
# 2  1.0  0.0  0.0

My original answer from 2015, which is now deprecated

You can use the convert_objects method of the DataFrame, with convert_numeric=True to change the strings to NaNs

From the docs:

convert_numeric: If True, attempt to coerce to numbers (including strings), with unconvertible values becoming NaN.

In [17]: df
Out[17]: 
    a   b  c
0  1.  2.  4
1  sd  2.  4
2  1.  fg  5

In [18]: df2 = df.convert_objects(convert_numeric=True)

In [19]: df2
Out[19]: 
    a   b  c
0   1   2  4
1 NaN   2  4
2   1 NaN  5

Finally, if you want to convert those NaNs to 0's, you can use df.replace

In [20]: df2.replace('NaN',0)
Out[20]: 
   a  b  c
0  1  2  4
1  0  2  4
2  1  0  5
2 of 3
6

Use .to_numeric to covert the strings to numeric (set strings to NaN using the errors option 'coerce'):

df = pd.to_numeric(df, errors='coerce')

and then convert the NaN value to zeros using replace:

df.replace('NaN',0)