In the pandas data frame, I'm trying to match df ['old_column'], apply the user-defined function f for each row, and create a new column.
df['new_column'] = df['old_column'].map(lambda x: f(x))
This yields "SettingWithCopyWarning: the value is trying to set to a copy of the slice from the DataFrame." error.
I tried the following:
df.loc[:, 'new_column'] = df['old_column'].map(lambda x: f(x))
which does not help. What can I do?
source
share