Pandas go to the new column, SettingWithCopyWarning

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?

+4
source share
1 answer

A SettingWithCopy pandas, , , . , pandas , , , , , ( ) .

. , :

pd.options.mode.chained_assignment = None

. fooobar.com/questions/24596/....

+3

Source: https://habr.com/ru/post/1669113/


All Articles