Working with Missing Data : 3. Filling and Verifying the Killed and Injured Data

I need clarification on below topic for the below mission.

Screen Link:

Your Code:

import numpy as np

# fix the killed values
killed['total_killed'] = killed['total_killed'].mask(killed['total_killed'].isnull(), killed_manual_sum)
killed['total_killed'] = killed['total_killed'].mask(killed['total_killed'] != killed_manual_sum, np.nan)

# Create an injured dataframe and manually sum values
injured = mvc[[col for col in mvc.columns if 'injured' in col]].copy()
injured_manual_sum = injured.iloc[:,:3].sum(axis=1)

injured_mask = injured_manual_sum != injured['total_injured']

injured['total_injured'] = injured['total_injured'].mask(injured['total_injured'].isnull(), injured_manual_sum)
injured['total_injured'] = injured['total_injured'].mask(injured_mask, np.nan)

What I expected to happen: I was expecting to clear this screen but instead I got a message that injured dataframe is not matching the expected result as shown in the below picture.

Please provide your feedback.

The difference here is that you define injured_mask before your first operation, and so when you use that mask it’s then out of date.

If you move your third last line of code to between the second last and last lines, it passes the answer checker.

Thanks for your feedback. That solution solved the problem.
So what I understand is whenever we want to use a mask variable, it should be defined just before the operation code line where it will be used.

The answer to that really depends on what you want the mask to be. Just think of it as a snapshot in time, so if you make changes after you create the mask, those changes won’t be updated in the mask itself.

Is there any way to inspect the expected result and compare it to our own result?
I made the same mistake as sreekanthac, and based on the small preview I had no way of finding out what the difference was.