Given that this is the top Google result when searching for "Pandas replace is not working" I'd like to also mention that:

replace does full replacement searches, unless you turn on the regex switch. Use regex=True, and it should perform partial replacements as well.

This took me 30 minutes to find out, so hopefully I've saved the next person 30 minutes.

Answer from Reddspark on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › pandas .replace not working
r/learnpython on Reddit: pandas .replace not working
December 31, 2015 -

This is genuinely driving me crazy.

I have a data frame of unit prices in string format i'm trying to get them to a float

item_df['Unit Price'] = item_df['Unit Price'].replace('$','')

and all the '$' are still there.

THEN when I do this:

item_df['Unit Price'][1] = item_df['Unit Price'][1].replace('$','')

The '$' is gone from that index ಠ_ಠ. What the hell is going on?? Am I taking crazy pills or missing some fundamental concept?

Any help would be much appreciated.

Thanks,

Why doesn’t my replace method work? Feb 22, 2022
r/learnpython
4y ago
Replace column using a dictionary and df.replace() Nov 29, 2021
r/learnpython
4y ago
Pandas issues Apr 6, 2023
r/learnpython
3y ago
More results from reddit.com
Discussions

Series.str.replace() is not actually the same as str.replace()
In [1]: import pandas as pd In [2]: series = pd.Series(['a', '(b)']) In [3]: series.str.replace('a', '[a]') Out[3]: 0 [a] 1 (b) dtype: object In [4]: series.str.replace('(b)', '[b]') # unexpected behavior Out[4]: 0 a 1 ([b]) dtype: object In [5]: series.str.replace('\(b\)', '[b]') # need to ... More on github.com
🌐 github.com
6
June 30, 2017
BUG: Pandas.DataFrame.str.replace function fails silently for mixed data mixing strings and float/int and replaces with NaN
Pandas version checks I have checked that this issue has not already been reported. I have confirmed this bug exists on the latest version of pandas. I have confirmed this bug exists on the main br... More on github.com
🌐 github.com
4
January 14, 2022
python - Replace method in pandas not giving expected result - Data Science Stack Exchange
- For each part get its length ... into one string with '.' between them. If using python2 you dont need the list. ... $\begingroup$ Yeah, it worked can you just explain join method in detail. Also, why do we need list over here $\endgroup$ ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... Community Asks Sprint Announcement – January 2026: Custom site-specific badges! 1 How to Replace an object in Pandas array using ... More on datascience.stackexchange.com
🌐 datascience.stackexchange.com
April 11, 2019
Problem with DataFrame.replace using None
It works fine if replaced with ... them to work very approximately the same. The expected output would be all strings matching the expression in replace to either 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
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.replace.html
pandas.Series.str.replace — pandas 3.0.6 documentation
Replacement string or a callable. The callable is passed the regex match object and must return a replacement string to be used.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.str.replace.html
pandas.Series.str.replace — pandas 3.0.5 documentation
Replacement string or a callable. The callable is passed the regex match object and must return a replacement string to be used.
🌐
GitHub
github.com › pandas-dev › pandas › issues › 16808
Series.str.replace() is not actually the same as str.replace() · Issue #16808 · pandas-dev/pandas
June 30, 2017 - In [1]: import pandas as pd In [2]: series = pd.Series(['a', '(b)']) In [3]: series.str.replace('a', '[a]') Out[3]: 0 [a] 1 (b) dtype: object In [4]: series.str.replace('(b)', '[b]') # unexpected behavior Out[4]: 0 a 1 ([b]) dtype: object In [5]: series.str.replace('\(b\)', '[b]') # need to escape Out[5]: 0 a 1 [b] dtype: object In [6]: '(b)'.replace('(b)', '[b]') # Python str.replace is different, uses literal string Out[6]: '[b]'
Author: pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 45372
BUG: Pandas.DataFrame.str.replace function fails silently for mixed data mixing strings and float/int and replaces with NaN · Issue #45372 · pandas-dev/pandas
January 14, 2022 - import pandas as pd import numpy as np list_of_random_numbers = np.random.randint(0,100,size=10) list_of_random_numbers_as_string = [str(x) for x in np.random.randint(0,100,size=10)] list_of_random_numbers_as_string[0] = list_of_random_numbers_as_string[0] + "'" df = pd.concat( [pd.DataFrame({'value':list_of_random_numbers}), pd.DataFrame({'value':list_of_random_numbers_as_string})], ignore_index=True) df['value'] = df['value'].str.replace("'", "") df.notnull().sum() When replacing a string in a column with mixed data, this replaces all non-string data with NaN without a warning (silent failur
Author: pandas-dev
🌐
HAR Data Extractor
jonathansoma.com › course › foundations-2021 › replacing-with-str-replace-and-replace
Replacing with .str.replace and .replace
If you try to do that with .str.replace, you get an error: replace() missing 1 required positional argument: 'repl'. This means "You didn't tell me what to replace with what," even though it feels like you tried. # This will not work df['edited'] = df.original.str.replace({ "potatoes": "chocolate", "love": "hate" }) df
🌐
Statology
statology.org › home › how to use str.replace in pandas (with examples)
How to Use str.replace in Pandas (With Examples)
April 11, 2024 - Often you may want to replace each occurrence of a particular pattern or substring in a pandas Series. The easiest way to do so is by using the str.replace() function, which uses the following basic syntax:
Find elsewhere
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › how to replace string in pandas dataframe
How to Replace String in Pandas DataFrame - Spark By {Examples}
June 13, 2025 - In pandas, to replace a string in the DataFrame column, you can use either the replace() function or the str.replace() method along with lambda methods.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-series-str-replace-to-replace-text-in-a-series
Python | Pandas Series.str.replace() to replace text in a series - GeeksforGeeks
July 11, 2025 - Example 1: Replacing values in age column In this example, all the values in age column having value 25.0 are replaced with "Twenty five" using str.replace() After that, a filter is created and passed in .where() method to only display the rows which have Age = "Twenty five".
🌐
GitHub
github.com › pandas-dev › pandas › issues › 26050
Problem with DataFrame.replace using None · Issue #26050 · pandas-dev/pandas
April 11, 2019 - It works fine if replaced with np.nan, but if anything, I would expect them to work very approximately the same. The expected output would be all strings matching the expression in replace to either 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: None pip: 19.0.3 setuptools: 40.6.2 Cython: None numpy: 1.16.0 scipy: 1.2.0 pyarrow: None xar
Author: pandas-dev
🌐
Towards Data Science
towardsdatascience.com › home › latest › 2 different replace functions of python pandas
2 Different Replace Functions of Python Pandas | Towards Data Science
January 20, 2025 - When the "str.replace" is used, the data type remains as string (or object). Thus, we need an extra step of data type conversion to have integers representing categories. We have learned two different replace function of Pandas and how they differ. There are cases where one of them is a better choice so it's best to know both. It is important to note that both these functions support regular expressions (i.e.
🌐
GitHub
github.com › pandas-dev › pandas › issues › 34993
BUG: replace method with regex=True does not work for byte string · Issue #34993 · pandas-dev/pandas
June 25, 2020 - import pandas as pd s = pd.Series([b'abc']) # This will replace "abc" with "123", output: # # 0 b'123' # dtype: object # print(s.replace(b'abc', b'123')) # But with regex=True, it doesn't work, output: # # 0 b'abc' # dtype: object # print(s.replace(b'abc', b'123', regex=True)) It worked in pandas 0.25. It also works when the data is unicode string instead of byte string.
Author: pandas-dev
🌐
GitHub
github.com › pandas-dev › pandas › issues › 24804
str.replace('.','') should replace every character? · Issue #24804 · pandas-dev/pandas
January 16, 2019 - import pandas as pd s = pd.Series(['abc','123']) s.str.replace('.','',regex = True) Out [1]: 0 abc 1 123 dtype: object · Hi everyone, I was showing str.replace to a colleague and how it uses regex by default and when I entered pd.Series.str.replace('.','') I expected every character to be removed but instead nothing happened.
Author: pandas-dev
🌐
Stack Overflow
stackoverflow.com › questions › 59883406 › remove-character-from-column-pandas-str-replace-not-working
python - Remove character from column Pandas. Str.replace() not working - Stack Overflow
I'm not sure, I don't think so. I'm exporting my data with the following code Fw_Queue_Clean.to_csv(r'C:\Users\j.cordoba\Desktop\Import_File_Jan_01222020(test5).csv',index=False). ... Got it to work!.... I took the suggestion given by the person that submitted the answer (Fw_Queue_Clean['Impressions'] = Fw_Queue_Clean['Impressions'].astype(str)). When I run that right before the str.replace() the column remains intact.