Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
df=pd.read_csv('abc.csv')
# using apply to perform some operation on a column:
df['columnname']=df.columnname.apply(lambda x: str(x).replace("original_value","new_value"))
Issue Description
The Apply operation can't be performed on a column itself. Provides the following error: SettingWithCopyError: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
Expected Behavior
Should allow me to explicitly perform the operation on the column itself and modify the dataframe.
Installed Versions
Comment From: phofl
Hi, thanks for your report.
Please provide a reproducible example that is copy-paste able.
https://matthewrocklin.com/minimal-bug-reports
Comment From: phofl
Closing for now, please ping to reopen when you can provide an example