Your replace format is off

In [21]: df = pd.DataFrame({'a':['Small', 'Medium', 'High']})

In [22]: df
Out[22]: 
        a
0   Small
1  Medium
2    High

[3 rows x 1 columns]

In [23]: df.replace({'a' : { 'Medium' : 2, 'Small' : 1, 'High' : 3 }})
Out[23]: 
   a
0  1
1  2
2  3

[3 rows x 1 columns]
Answer from Jeff on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › pandas-replace-multiple-values-in-python
Pandas Replace Multiple Values in Python - GeeksforGeeks
July 23, 2025 - One of Pandas most useful tools is the replace() method, which allows to substitute desired values with specified ones.
Discussions

Replace multiple values in a single column Pandas
That error means that you can't use a data frame series as the key in a dictionary. All dictionary keys must be hashable. Moot point anyway, since you can't use str.replace that way. I'm guessing you were looking for str.translate, but that won't work either since it only works to replace characters. You need to make your own function that can convert a single string using a loop. More on reddit.com
🌐 r/learnpython
8
1
February 6, 2017
How do I replace multiple unique values in a single column w/Pandas?
Panda's replace allows you to replace multiple values in a column using a dictionary - https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.replace.html Something like this: df.replace({'street': {'Paper Street': 'Rock Street', 'Scissors Street': 'Rock Street'}}) More on reddit.com
🌐 r/Python
3
2
April 5, 2018
Vectorized .str.replace() for multiple characters in pandas
I think my count and year columns are breaking because of the if statement excluding those two columns. More on reddit.com
🌐 r/learnpython
3
1
June 9, 2022
Pandas - using .apply to replace multiple columns in a row?
I'm confused about how to set the following up. I have a data frame with say 10 columns I want to set up .apply so that for each row, if the first … More on reddit.com
🌐 r/learnpython
4
3
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.replace.html
pandas.DataFrame.replace — pandas 3.0.5 documentation
For a DataFrame a dict can specify that different values should be replaced in different columns. For example, {'a': 1, 'b': 'z'} looks for the value 1 in column ‘a’ and the value ‘z’ in column ‘b’ and replaces these values with whatever is specified in value.
🌐
Python Guides
pythonguides.com › pandas-replace-multiple-values
Replace Multiple Values In Pandas DataFrame Using Str.Replace()
May 22, 2025 - # Replace values across the entire DataFrame df_replaced = df.replace({ 'California': 'CA', 'New York': 'NY', 1200: 'Low Sales', 1500: 'High Sales' }) print("\nDataFrame after multiple replacements:") print(df_replaced) Check out Convert DataFrame To NumPy Array Without Index in Python · The loc[] method in Python allows you to replace values based on conditions, which gives you more flexibility. Here’s an example with sales data categorization: import pandas as pd # Sample US sales data data = { 'Product': ['Laptop', 'Smartphone', 'Tablet', 'Monitor', 'Keyboard'], 'Sales': [1200, 1800, 950
🌐
datagy
datagy.io › home › pandas tutorials › pandas dataframes › pandas replace() – replace values in pandas dataframe
Pandas replace() - Replace Values in Pandas Dataframe • datagy
March 2, 2023 - Learn how to use the Pandas replace method to replace values across columns and dataframes, including with regular expressions.
🌐
Python Examples
pythonexamples.org › pandas-dataframe-replace-multiple-values
Pandas DataFrame - Replace Multiple Values
The syntax to replace multiple values in a column of DataFrame is · DataFrame.replace({'column_name' : { old_value_1 : new_value_1, old_value_2 : new_value_2}}) In the following example, we will use replace() method to replace 1 with 11 and 2 with 22 in column a. import pandas as pd df = ...
🌐
AskPython
askpython.com › home › replace multiple values in a dataset using pandas
Replace Multiple Values in a Dataset using Pandas - AskPython
February 16, 2023 - import pandas as pd data = pd.DataFrame([ ['Jack',25,'USA'], ['Rohan',20,'India'], ['Sam',23,'France'], ['Rini',19,'UK'], ['Tywin',16,'Ireland']], columns=['Name','Age', 'Country']) print (data) print('\n') new_data = data.replace({'Country':{'USA':'India'}}) print (new_data) updated_data = new_data.replace({'Age': {25:23, 16:18}, 'Name':{'Tywin':'Stark'}}) print('\n') print(updated_data)
Find elsewhere
🌐
Statology
statology.org › home › pandas: how to replace multiple values in one column
Pandas: How to Replace Multiple Values in One Column
September 27, 2022 - This tutorial explains how to replace multiple values in one column of a pandas DataFrame, including an example.
🌐
ProjectPro
projectpro.io › recipes › replace-multiple-values-in-pandas-dataframe
How to replace multiple values in a Pandas DataFrame? -
January 19, 2023 - to_replace : In this we have to pass the data of any type(string, int, floatetc) which we want to replace. value : In this we have to pass the data of any type(string, int, floatetc) which we want to insert in the place of the data we want to ...
🌐
AskPython
askpython.com › home › how to replace multiple values using pandas?
How to Replace Multiple Values using Pandas? - AskPython
January 28, 2023 - But, what hasn’t been done is that the values substituted have never been mapped to the data frame! One can very well do this by using the following syntax, df[‘column header’]=df[‘column header’].map(vals_to_replace)
🌐
Data to Fish
datatofish.com › replace-values-pandas-dataframe
How to Replace Values in a pandas DataFrame
# replace one specific value in a column df['column_a'] = df['column_a'].replace("x", "y") # replace multiple values (x, y) with one value (z) in a column df['column_a'] = df['column_a'].replace(["x", "y"], "z") # replace values (w, x) with other values (y, z) in a column df['column_a'] = df['column_a'].replace(["w", "x"], ["y", "z"]) # replace one specific value in the entire df df = df.replace("x", "y") ... That's it! You just learned how to replace values in a pandas DataFrame.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-replace-multiple-values-in-one-column-using-pandas
How to Replace Multiple Values in One Column using Pandas | Saturn Cloud Blog
May 1, 2026 - It provides data structures for ... analysis. To replace multiple values in one column of a Pandas DataFrame, we can use the replace() method....
🌐
Reddit
reddit.com › r/learnpython › replace multiple values in a single column pandas
r/learnpython on Reddit: Replace multiple values in a single column Pandas
February 6, 2017 -

I am trying to replace parts of a single column string but keep running into an error. Please help anyone.

import pandas as pd

first = pd.read_csv('C:/Users/DATA INPUT.csv')
first['Address'] = str.replace({first['Address']: {'Ln': 'Lane','Dr': 'Drive','Rd' :
                                               'Road','Ct': 'Court','Dr.': 'Drive',
                                               'St': 'Street','Ave': 'Avenue',
                                               'Crk':'Creek Way', 'Rdg' : 'Ridge'}})

Error:

Traceback (most recent call last):
  File "C:\datainputcombo.py", line 8, in <module>
File "C:\Users\Programs\Python\Python36-32\lib\site-packages\pandas\core\generic.py", line 831, in __hash__
' hashed'.format(self.__class__.__name__))
TypeError: 'Series' objects are mutable, thus they cannot be hashed
🌐
PythonForBeginners.com
pythonforbeginners.com › home › pandas replace values in dataframe or series
Pandas Replace Values in Dataframe or Series - PythonForBeginners.com
January 9, 2023 - Instead of using the lists, you can pass a python dictionary to the replace() method to replace multiple values in a series with different values. For this, we will first create a dictionary that contains the values that have to be replaced as keys and the replacements as the associated value ...
🌐
CodeForGeek
codeforgeek.com › home › replace multiple values in a dataframe using pandas
Replace Multiple Values in a DataFrame Using Pandas | CodeForGeek
September 30, 2023 - If we want to replace values of a DataFrame based on certain conditions then we can use the loc[] attribute. It takes in the names of rows and columns respectively as indices and returns values from the DataFrame.
🌐
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 - Thanks to the flexibility of Pandas, we can do both replacements in a single operation. Each replacement is written as a key-value pair in the dictionary. ... Both "doc" and "eng" have been replaced. There is another way of replacing multiple values in a column, which is using Python lists to indicate values to be replaced and the new ones.
🌐
GeeksforGeeks
geeksforgeeks.org › data analysis › python-pandas-dataframe-replace
Python | Pandas dataframe.replace() - GeeksforGeeks
Replacing more than one value at a time. Using python list as an argument We are going to replace team "Boston Celtics" and "Texas" with "Omega Warrior" in the 'df' Dataframe. ... # importing pandas as pd import pandas as pd # Making data frame from the csv file df = pd.read_csv("nba.csv") # this will replace "Boston Celtics" and "Texas" with "Omega Warrior" df.replace(to_replace=["Boston Celtics", "Texas"], value="Omega Warrior")
Published: July 11, 2025
🌐
DataCamp
campus.datacamp.com › courses › writing-efficient-code-with-pandas › replacing-values-in-a-dataframe
Replace multiple values II | Python
In the DataFrame names, you are going to replace all the values on the left by the values on the right. ... Replace all the ethnicities by their respective alternative, as indicated above. Have a go at this exercise by completing this sample code. start_time = time.time() # Replace ethnicities as instructed names['Ethnicity'].replace([____,____, ____], [____,____,____], inplace=True) print("Time using .replace(): {} sec".format(time.time() - start_time))
🌐
IncludeHelp
includehelp.com › python › pandas-replace-multiple-values-one-column.aspx
Python - Pandas replace multiple values one column
October 3, 2023 - For this purpose, we will use the concept of a dictionary, we will first create a DataFrame and then we will replace the column by passing a dictionary inside replace method. In this dictionary, we will pass all the values in form of column values and the keys will represent the new values.
🌐
Statology
statology.org › home › how to replace values in a pandas dataframe (with examples)
How to Replace Values in a Pandas DataFrame (With Examples)
September 27, 2022 - The following code shows how to replace multiple values in a single column: #replace 6, 11, and 8 with 0, 1 and 2 in rebounds column df['rebounds'] = df['rebounds'].replace([6, 11, 8], [0, 1, 2]) #view DataFrame print(df) team division rebounds 0 A E 1 1 A W 2 2 B E 7 3 B E 0 4 B W 0 5 C W 5 6 C E 12 · The following tutorials explain how to perform other common tasks in pandas: