Analyze Employees Exit Surveys - step 7 - use of df.copy()

Screen Link:

Hello to everyone!
I would like to clarify the instructions regardying the df.copy() method. Do we have to apply it after we create the new ‘dissatisfied’ column to avoid the SettingWithCopy Warning in some future steps or do we have to do it before all the manipulations of this step?

1 Like

Hello @ksenia.kustanovich

Yes! you need to create a copy of the results after creating a dissatisfied column in both dataframes using DataFrame.any() method to avoid the SettingWithCopy Warning.

Below is the quick reference code-

Passing a fucntion to all values and creating a new column

dete_resignations[‘dissatisfied’] = dete_resignations[cols].any(axis=1, skipna=False)

Creating a copy of the result

dete_resignations_up = dete_resignations.copy()

Hope it helps.