Guided Project: Clean And Analyze Employee Exit Surveys- Answers

Hi Everyone,

I believe there are multiple ways of achieving the same results. So my question is, is it necessary to follow the approach given in the answers?

for example. the code in the solution for isolating the separation type ‘Resgination’ is

# Update all separation types containing the word “resignation” to 'Resignation’
dete_survey_updated[‘separationtype’] = dete_survey_updated[‘separationtype’].str.split(’-’).str[0]

# Check the values in the separationtype column were updated correctly

Select only the resignation separation types from each dataframe
dete_resignations = dete_survey_updated[dete_survey_updated[‘separationtype’] == ‘Resignation’].copy()
tafe_resignations = tafe_survey_updated[tafe_survey_updated[‘separationtype’] == ‘Resignation’].copy()

while I have achieved the same thing from the following code

tafe_resignations =tafe_survey_updated[tafe_survey_updated [‘separationtype’]==‘Resignation’]
dete_resignations =dete_survey_updated[ dete_survey_updated[‘separationtype’].str.contains(‘Resignation’)]

Hi @tyche2k I think that we go for the answers when get stuck which to me , should be the last option. Once your code works, I don’t think if it is necessary to open again the answer section. But you can as well do so just for curiosity.

I have actually done the same b-indexing method as you, and wasn’t exactly sure as to why we’re instructed to use the other methods instead. Does it really matter, at least in a professional setting? Would love to know the pros and cons of each approach.

edit: just note however if you do take this approach, you still need to chain .copy().

1 Like

Totally agree. I was stuck in the guideline

*** Use the DataFrame.copy() method on the result to avoid the SettingWithCopy Warning.**

Thats why I reached out to answers to have a peek

why the .copy() need to be chained. Didn’t understood

To avoid the SettingWithCopy Warning further down the project