You need to select that column:

In [41]:
df.loc[df['First Season'] > 1990, 'First Season'] = 1
df

Out[41]:
                 Team  First Season  Total Games
0      Dallas Cowboys          1960          894
1       Chicago Bears          1920         1357
2   Green Bay Packers          1921         1339
3      Miami Dolphins          1966          792
4    Baltimore Ravens             1          326
5  San Franciso 49ers          1950         1003

So the syntax here is:

df.loc[<mask>(here mask is generating the labels to index) , <optional column(s)> ]

You can check the docs and also the 10 minutes to pandas which shows the semantics

EDIT

If you want to generate a boolean indicator then you can just use the boolean condition to generate a boolean Series and cast the dtype to int this will convert True and False to 1 and 0 respectively:

In [43]:
df['First Season'] = (df['First Season'] > 1990).astype(int)
df

Out[43]:
                 Team  First Season  Total Games
0      Dallas Cowboys             0          894
1       Chicago Bears             0         1357
2   Green Bay Packers             0         1339
3      Miami Dolphins             0          792
4    Baltimore Ravens             1          326
5  San Franciso 49ers             0         1003
Answer from EdChum on Stack Overflow
๐ŸŒ
Spark By {Examples}
sparkbyexamples.com โ€บ home โ€บ pandas โ€บ pandas replace values based on condition
Pandas Replace Values based on Condition - Spark By {Examples}
June 18, 2025 - You can replace all values or selected values in a column of pandas DataFrame based on condition by using DataFrame.loc[], np.where() and DataFrame.mask()
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-replace-all-values-in-a-pandas-dataframe-column-based-on-a-condition
How to Replace All Values in a Pandas DataFrame Column Based on a Condition | Saturn Cloud Blog
May 1, 2026 - As a data scientist or software engineer you may come across a situation where you need to replace all values in a Pandas DataFrame column based on a certain condition This can be easily achieved using the powerful DataFrame capabilities of Pandas library in Python
Discussions

python - Pandas DataFrame: replace all values in a column, based on condition - Stack Overflow
I have a simple DataFrame like the following: Team First Season Total Games 0 Dallas Cowboys 1960 894 1 Chicago Bears 1920 1357 2 Green Bay Packers 1921 1339 3 Miami Dolphins 1966 792 4 Baltimore R... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to replace all value in all columns in a Pandas dataframe with condition - Stack Overflow
1 How can all values of certain included or excluded columns of a DataFrame be impuded based on a condition? 295 Pandas DataFrame: replace all values in a column, based on condition More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 22, 2017
how to update a pandas dataframe column value, when a specific string appears in another column?
It's not something you'd really use .apply for. You would use boolean indexing, e.g. df['A'].str.contains('foo') would give you a Series of True/False values. You can then use .loc to set column(s) to a particular value for the True rows: df.loc[df['A'].str.contains('foo'), 'B'] = 'bar' More on reddit.com
๐ŸŒ r/learnpython
7
3
June 24, 2024
A most efficient way of using conditional replacement in pandas
You can assign multiple columns to the same value at the same time. >>> df foo bar baz 0 1 4 7 1 2 5 8 2 1 6 9 >>> df.loc[ df['foo'] == 1, ['baz', 'bar']] = '-' >>> df foo bar baz 0 1 - - 1 2 5 8 2 1 - - It's .loc[rows, columns] = value >>> rows = df['foo'] == 1 >>> columns = 'bar', 'baz' >>> df.loc[rows, columns] = '-' >>> df foo bar baz 0 1 - - 1 2 5 8 2 1 - - More on reddit.com
๐ŸŒ r/learnpython
2
1
November 9, 2022
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ data analysis โ€บ how-to-replace-values-in-column-based-on-condition-in-pandas
How to Replace Values in Column Based on Condition in Pandas? - GeeksforGeeks
November 15, 2024 - The apply() function in combination with a lambda function is a flexible method for applying conditional replacements based on more complex logic. Here, we will replace 'female' with 0 in the gender column using the apply() function and lambda.
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.replace.html
pandas.DataFrame.replace โ€” pandas 3.0.5 documentation
Replace values based on boolean condition. ... Apply a function to a Dataframe elementwise. ... Map values of Series according to an input mapping or function. ... Simple string replacement. ... Regex substitution is performed under the hood with re.sub. The rules for substitution for re.sub are the same. Regular expressions will only substitute on strings, meaning you cannot provide, for example, a regular expression matching floating point numbers and expect the columns in your frame that have a numeric dtype to be matched.
๐ŸŒ
IncludeHelp
includehelp.com โ€บ python โ€บ how-to-replace-all-values-in-a-column-based-on-condition.aspx
Pandas: How to replace all values in a column, based on condition?
September 21, 2023 - # Importing pandas package import pandas as pd # creating a dictionary of student marks d = { "Players":['Sachin','Ganguly','Dravid','Yuvraj','Dhoni','Kohli'], "Format":['ODI','ODI','ODI','ODI','ODI','ODI'], "Runs":[15921,7212,13228,1900,4876,8043] } # Now we will create DataFrame df = pd.DataFrame(d) # Viewing the DataFrame print("DataFrame:\n",df,"\n\n") # Replacing thr values of column Format df.loc[(df.Format == 'ODI' ), 'Format'] = 'TEST' # Display modified DataFrame print("Modified DataFrame:\n",df)
Find elsewhere
๐ŸŒ
Statology
statology.org โ€บ home โ€บ pandas: how to replace values in column based on condition
Pandas: How to Replace Values in Column Based on Condition
October 26, 2021 - #replace any values in 'points' column greater than 10 with 20 df.loc[df['points'] > 10, 'points'] = 20 #view updated DataFrame df team position points assists 0 A G 5 3 1 A G 7 8 2 A F 7 2 3 A F 9 6 4 B G 20 6 5 B G 20 5 6 B F 9 9 7 B F 20 5
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ conditional-replacement-in-pandas-a-quick-guide-for-data-scientists
Conditional Replacement in Pandas A Quick Guide for Data Scientists | Saturn Cloud Blog
May 1, 2026 - This can be done using pandas' replace method, which allows you to specify the value to replace and the replacement value based on a condition. To perform conditional replacement in pandas, you can use the replace method on a DataFrame or a ...
๐ŸŒ
Python Examples
pythonexamples.org โ€บ pandas-dataframe-replace-values-in-column-based-on-condition
Pandas DataFrame - Replace values in column based on condition
In the following program, we will replace those values in the column 'a' that satisfy the condition that the value is less than zero. import pandas as pd df = pd.DataFrame([ [-10, -9, 8], [6, 2, -4], [-8, 5, 1]], columns=['a', 'b', 'c']) df.loc[(df.a < 0), 'a'] = 0 print(df)
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ pandas
pandas: Replace values based on conditions with where(), mask() | note.nkmk.me
January 17, 2024 - This article explains how to replace values based on conditions in pandas. You can perform conditional operations like if then ... or if then ... else ... on DataFrame or Series. Use the where() metho ...
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ pandas โ€บ conditional changes in pandas dataframe
Conditional Changes in Pandas Dataframe - Scaler Topics
May 4, 2023 - With the help of pandas DataFrame.loc[] property, values of the selected columns based on the provided condition of the pandas DataFrame can be replaced. By using a label or boolean array, the loc[] allows you to access a collection of rows and columns.
๐ŸŒ
Favtutor
favtutor.com โ€บ articles โ€บ pandas-replace-column-values
Pandas DataFrame: Replace Column Values (with code)
December 15, 2023 - We can use the loc() indexer method to replace values based on a condition. This allows us to select specific rows and columns of a DataFrame and modify their values. ... import pandas as pd data = {'Name': ['Alice', 'Bob', 'Charlie', 'David'], ...
๐ŸŒ
Skytowner
skytowner.com โ€บ explore โ€บ replacing_values_in_a_dataframe_in_pandas
Replacing values in a DataFrame in Pandas
Replacing a value in entire ... 100+ top-tier guides Start your free 7-days trial now! To replace values in a Pandas DataFrame, use the DataFrame's replace(~) method....
๐ŸŒ
Medium
medium.com โ€บ @RedHairedGirl โ€บ pandas-dataframe-a-comprehensive-guide-to-replace-values-based-on-condition-27d89d830bb4
Pandas DataFrame: A Comprehensive Guide to Replace Values Based on Condition - RedHairedGirl (aka PLIM) - Medium
November 21, 2024 - For a pandas DataFrame, there are various ways to replace the values in a column. In this Jupyer Notebook, I have illustrated most (if not all) of the ways one could use to replace the values based on 1โ€“2 conditions, or to replace values with that in another column.
๐ŸŒ
Kanoki
kanoki.org โ€บ 2019 โ€บ 07 โ€บ 17 โ€บ pandas-how-to-replace-values-based-on-conditions
Pandas How to replace values based on Conditions | kanoki
July 17, 2019 - Replace all the Dance in Column Event with Hip-Hop ยท df.loc[(df.Event == 'Dance'),'Event']='Hip-Hop' df ... df = pd.DataFrame([[1.4, 8], [1.2, 5], [0.3, 10]], index=['China', 'India', 'USA'], columns=['Population(B)', 'Economy']) ... DataFrames are a powerful tool for working with data in Python, and Pandas provides a number of ways to count duplicate rows in a DataFrame.
๐ŸŒ
Arab Psychology
scales.arabpsychology.com โ€บ psychological scales โ€บ how to use pandas to replace values in column based on condition
How To Use Pandas To Replace Values In Column Based On Condition
November 15, 2023 - Pandas provides a method called .loc to replace values in a column based on condition. It takes a list of conditions as the first argument and a list of values to replace the conditions with as the second argument. The syntax is df.loc[conditions, โ€˜columnโ€™] = new_values.
๐ŸŒ
RS Blog
reneshbedre.com โ€บ blog โ€บ replace-column-values-based-on-condition-pandas.html
How to replace column values in pandas DataFrame based on column conditions
December 18, 2022 - This method is more suitable if you want to update the large number of values based on condition in a column. ... condition: conditional expression true_value: Old value will be replaced with this true value if the condition is True false_value: Old value will be replaced with this value if the condition is False ยท import pandas as pd # create a random dataframe df = pd.DataFrame({'name':['Adams', 'Jones', 'Frank', 'Smith', 'Davis'], 'age':[25, 30, 28, 35, 22], 'weight':[74, 90, 85, 65, 92]}) # output name age weight 0 Adams 25 74 1 Jones 30 90 2 Frank 28 85 3 Smith 35 65 4 Davis 22 92 # replace the weight value with 92 if it is 90 df['weight'].mask(df['weight'] == 90, 98, inplace=True) # output name age weight 0 Adams 25 74 1 Jones 30 98 2 Frank 28 85 3 Smith 35 65 4 Davis 22 92