Your regex is matching on all - characters:

In [48]:
df_raw.replace(['-','\*'], ['0.00','0.00'], regex=True)

Out[48]:
       A          B
0   1.00        1.0
1  0.001  0.0045.00
2    NaN       0.00

If you put additional boundaries so that it only matches that single character with a termination then it works as expected:

In [47]:
df_raw.replace(['^-$'], ['0.00'], regex=True)

Out[47]:
      A       B
0  1.00     1.0
1    -1  -45.00
2   NaN    0.00

Here ^ means start of string and $ means end of string so it will only match on that single character.

Or you can just use replace which will only match on exact matches:

In [29]:

df_raw.replace('-',0)
Out[29]:
      A       B
0  1.00     1.0
1    -1  -45.00
2   NaN       0
Answer from EdChum on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.replace.html
pandas.Series.str.replace — pandas 3.0.5 documentation
>>> pat = r"(?P<one>\w+) (?P<two>\w+) (?P<three>\w+)" >>> repl = lambda m: m.group("two").swapcase() >>> ser = pd.Series(["One Two Three", "Foo Bar Baz"]) >>> ser.str.replace(pat, repl, regex=True) 0 tWO 1 bAR dtype: str
🌐
Python documentation
docs.python.org › 3 › howto › regex.html
Regular expression HOWTO — Python 3.14.7 documentation
The optional argument count is the maximum number of pattern occurrences to be replaced; count must be a non-negative integer. The default value of 0 means to replace all occurrences. Here’s a simple example of using the sub() method.
Discussions

python - pandas: Dataframe.replace() with regex - Stack Overflow
0 Why can't I replace string for this symbol in DataFrame? 1 How would I change/remove 'non-printable' characters e.g  from df.columns values incorporating the regex statements already in place More on stackoverflow.com
🌐 stackoverflow.com
Why have to add regex = True to get .replace to work (pandas)
Df["colname"].str.replace("this", "that") This is how it's done More on reddit.com
🌐 r/learnpython
7
3
March 29, 2022
regex - Python string.replace regular expression - Stack Overflow
I have a parameter file of the form: parameter-name parameter-value Where the parameters may be in any order but there is only one parameter per line. I want to replace one parameter's parameter-... More on stackoverflow.com
🌐 stackoverflow.com
python .replace() regex - Stack Overflow
For anything in production, I would ... either regex or simple string search can accomplish. 2018-03-03T18:42:42.197Z+00:00 ... Save this answer. ... Show activity on this post. For this particular case, if using re module is overkill, how about using split (or rsplit) method as ... Copy#!/usr/bin/python ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.replace.html
pandas.DataFrame.replace — pandas 3.0.5 documentation
>>> s.replace("a", None) 0 10 1 None 2 None 3 b 4 None dtype: object · When regex=True, value is not None and to_replace is a string, the replacement will be applied in all columns of the DataFrame.
🌐
Index.dev
index.dev › blog › regex-advanced-string-replacement-python
Python Regex Replace: How to Replace Strings Using re Module
In this example, the word "World" is replaced with "Universe" using the regex pattern r"World". This is a straightforward use of re.sub(), but the true power of regex becomes apparent when you start using more complex patterns.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.7 ...
However, Unicode strings and 8-bit strings cannot be mixed: that is, you cannot match a Unicode string with a bytes pattern or vice-versa; similarly, when asking for a substitution, the replacement string must be of the same type as both the pattern and the search string. Regular expressions use the backslash character ('\') to indicate special forms or to allow special characters to be used without invoking their special meaning. This collides with Python’s usage of the same character for the same purpose in string literals; for example, to match a literal backslash, one might have to write '\\\\' as the pattern string, because the regular expression must be \\, and each backslash must be expressed as \\ inside a regular Python string literal.
🌐
Machine Learning Plus
machinelearningplus.com › blog › regex replace values using pandas
RegEx Replace values using Pandas - machinelearningplus
March 8, 2022 - In this article, we explain how ... with examples · For using pandas replace function with regex, you need to define 3 parameters: to_replace, regex and value. to_replace: Denotes the value that has to be replaced in the dataframe or series. In the case of regular expressions, a regex pattern has to be passed. This pattern represents a generic sequence of characters. regex: For pandas to interpret the replacement as regular expression replacement, set it to True...
Find elsewhere
🌐
Squash
squash.io › how-to-replace-regex-in-python
How To Replace Text with Regex In Python - Squash Labs
September 24, 2023 - In this example, the regex pattern [aeiou] matches any vowel in the input string. The occurrences of the vowels are replaced with asterisks using the re.sub() function. Related Article: How to Work with Encoding & Multiple Languages in Django · Another approach to replacing regex patterns in Python is by using regex groups and backreferences.
🌐
Google
developers.google.com › google for education › python › python regular expressions
Python Regular Expressions | Python Education | Google for Developers
The replacement string can include '\1', '\2' which refer to the text from group(1), group(2), and so on from the original matching text. Here's an example which searches for all the email addresses, and changes them to keep the user (\1) but ...
🌐
Reddit
reddit.com › r/learnpython › why have to add regex = true to get .replace to work (pandas)
r/learnpython on Reddit: Why have to add regex = True to get .replace to work (pandas)
March 29, 2022 -

Hello Very new to pandas. Trying to replace ampersand in my excel file

Why did I have to add regex=True to get this to work. It wouldn’t update otherwise.

df = df.replace(‘%26’ , ‘&’ , regex = True)

🌐
Dive into Python
diveintopython.org › home › learn python programming › regex in python
RegEx in Python: Match and Replace Basics with Examples
May 3, 2024 - This powerful technique allows you to search for patterns within strings and replace them with desired text, making data manipulation smoother than ever. Whether you're working with data cleaning, processing, or even web scraping, understanding how to utilize Python string replace regex can significantly enhance your coding efficiency. Here's a concise guide with practical examples to get you started:
🌐
Codedamn
codedamn.com › news › python
Python replace regex for searching and replacing strings
July 1, 2023 - In this example, the re.sub() function is used to replace all occurrences of 'codedamn' with 'CODEDAMN'. The output would be: Hello, CODEDAMN coders! Welcome to CODEDAMN community! The real power of regex comes with its ability to use special characters to construct search patterns, making it a vital tool for string manipulations in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-substituting-patterns-in-text-using-regex
Python - Substituting patterns in text using regex - GeeksforGeeks
July 12, 2025 - Syntax: re.sub(pattern, repl, string, ... 1: Substitution of a specific text pattern In this example, a given text pattern will be searched and substituted in a string....
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python string tutorial › python regex replace
Python regex replace | Learn the Parameters of Python regex replace
May 13, 2024 - In Python, we use replace() function in the string concept, and it cannot be used for replacing the substring, or part of string were to replace() function is used to replace the entire string; hence to do this, we use regular expression which provides “re” module and to replace part of the string we use sub() function as we saw how simple it is to use this function for replacing the given pattern in the actual string to obtain the modified string. This is mainly used for replacing special characters with spaces or some other characters to make the string readable. This is a guide to Python regex replace.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
w3resource
w3resource.com › pandas › series › series-replace.php
Pandas Series: replace() function - w3resource
Example - Regular expression 'to_replace': Python-Pandas Code: import numpy as np import pandas as pd df = pd.DataFrame({'X': ['bbb', 'fff', 'bii'], 'Y': ['abc', 'brr', 'pqr']}) df.replace(to_replace=r'^ba.$', value='new', regex=True) Output: X Y 0 bbb abc 1 fff brr 2 bii pqr ·
🌐
w3tutorials
w3tutorials.net › blog › replacing-specific-words-in-a-string-python
Python Regex Guide: How to Replace Specific Words in a String – Substituting $noun$ and $verb$ Placeholders
Python’s built-in re module provides tools to work with regex. The star of the show for substitution is re.sub(), which replaces all non-overlapping matches of a pattern in a string. ... Our goal is to replace placeholders like $noun$ and $verb$ in a string (e.g., "I $verb$ the $noun$") with actual words (e.g., "I feed the dog").
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › replace-values-in-pandas-dataframe-using-regex
Replace Values in Pandas Dataframe using Regex - GeeksforGeeks
October 9, 2025 - Explanation: The regex [nN]ew matches both "New" and "new", replacing them with "New_" across the entire DataFrame column. The apply() function lets you define a custom function that uses Python’s re module for pattern matching and string replacement. This is useful when the cleanup logic is more complex than simple substitution. In this example, city names containing additional details inside brackets (e.g., "New York (City)") are cleaned by removing the bracketed part.