This should do it for you:

# Find the name of the column by index
n = df.columns[1]

# Drop that column
df.drop(n, axis = 1, inplace = True)

# Put whatever series you want in its place
df[n] = newCol

...where [1] can be whatever the index is, axis = 1 should not change.

This answers your question very literally where you asked to drop a column and then add one back in. But the reality is that there is no need to drop the column if you just replace it with newCol.

Answer from elPastor on Stack Overflow
๐ŸŒ
Pandas
pandas.pydata.org โ€บ docs โ€บ reference โ€บ api โ€บ pandas.DataFrame.replace.html
pandas.DataFrame.replace โ€” pandas 3.0.5 documentation
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. The value parameter should not be None in this case. You can treat this as a special case of passing two lists except ...
Discussions

python - pandas replace values of a list column - Stack Overflow
Communities for your favorite technologies. Explore all Collectives ยท Ask questions, find answers and collaborate at work with Stack Overflow for Teams More on stackoverflow.com
๐ŸŒ stackoverflow.com
pandas - Replacing few values in a column based on a list in python - Stack Overflow
here is one good explained topic on stackoverflow: Replacing few values in a pandas dataframe column with another value The example is: BrandName Specialty A H B I ABC J ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
October 9, 2019
python - Replace items in column based on list - Stack Overflow
I have a dataframe like so: Date Value 19990506 0.6 19990506 0.8 19990607 1.2 20000802 0.4 and I also have two lists like this: list1 = ['19990506', '19990607', '20000802'] lis... More on stackoverflow.com
๐ŸŒ stackoverflow.com
April 19, 2016
Best way to replace values in one column from another column in pandas?
No, you shouldn't be looping. You should generally avoid that in Pandas. You can assign directly with loc: df.loc[df['new_items'] != 0, 'old_items'] = df['new_items'] or use an apply function: df['old_items'] = df.apply(lambda row: row['new_items'] if row['new_items'] != 0 else row['old_items']) More on reddit.com
๐ŸŒ r/learnpython
2
1
October 20, 2022
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ third-party โ€บ pandas โ€บ DataFrame โ€บ replace
Python Pandas DataFrame replace() - Replace Values | Vultr Docs
December 27, 2024 - Pandas replace() method is a powerful and flexible tool to modify DataFrame elements based on specified conditions. This function allows for the replacement of a list of values with another list, substitution of a pattern in a DataFrame, or ...
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python โ€บ pandas
pandas: Replace values in DataFrame and Series with replace() | note.nkmk.me
January 17, 2024 - In pandas, the replace() method allows you to replace values in DataFrame and Series. It is also possible to replace parts of strings using regular expressions (regex). pandas.DataFrame.replace โ€” pan ...
๐ŸŒ
Python Course
python-course.eu โ€บ numerical-programming โ€บ accessing-and-changing-values-dataframes.php
27. Accessing and Changing values of DataFrames | python-course.eu
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. The value parameter should not be None in this case. You can treat this as a special case of passing two lists except that you are specifying the column to search in.
Find elsewhere
๐ŸŒ
Pandas
pandas.pydata.org โ€บ pandas-docs โ€บ version โ€บ 2.1 โ€บ reference โ€บ api โ€บ pandas.DataFrame.replace.html
pandas.DataFrame.replace โ€” pandas 2.1.4 documentation
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. The value parameter should not be None in this case. You can treat this as a special case of passing two lists except that you are specifying the column to search in.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ best way to replace values in one column from another column in pandas?
r/learnpython on Reddit: Best way to replace values in one column from another column in pandas?
October 20, 2022 -

Original range:

old_items new_items
item1 item6
item2 0
item3 item7
item4 0
item5 item8

Desired output:

old_items new_items
item6 item6
item2 0
item7 item7
item4 0
item8 item8

My stupid solution:

old_items = list(df['old_items'])
new_items = list(df['new_items'])
proper_items = []

for x in range(len(old_items)):
    if new_items[x] != 0:
        proper_items.append(new_items[x])
    else:
        proper_items.append(old_items[x])

df['old_items'] = proper_items
๐ŸŒ
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()
๐ŸŒ
w3resource
w3resource.com โ€บ pandas โ€บ series โ€บ series-replace.php
Pandas Series: replace() function - w3resource
import numpy as np import pandas as pd s = pd.Series([10, 'p', 'p', 'q', 'p']) s.replace({'p': None}) ... When value=None and to_replace is a scalar, list or tuple, replace uses the method parameter (default โ€˜padโ€™) to do the replacement.
๐ŸŒ
Python Guides
pythonguides.com โ€บ pandas-replace-multiple-values
Replace Multiple Values In Pandas DataFrame Using Str.Replace()
May 22, 2025 - 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': ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ 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.0 documentation
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. The value parameter should not be None in this case. You can treat this as a special case of passing two lists except that you are specifying the column to search in.
๐ŸŒ
pandas
pandas.pydata.org โ€บ pandas-docs โ€บ dev โ€บ reference โ€บ api โ€บ pandas.DataFrame.replace.html
pandas.DataFrame.replace โ€” pandas 3.1.0.dev0 documentation
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. The value parameter should not be None in this case. You can treat this as a special case of passing two lists except ...
๐ŸŒ
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'] = ...