I am working on this dataset called titanic.csv Let's simplify the problem and include some data here:
I need to calculate all missing values for child, as you see it is a value under who column. This should be done using a pivot table.
I have tried this solution:
pd.pivot_table(df[df['who'] == 'child'],
index='sex',
aggfunc=lambda x: x.isnull().sum(),
margins=True) # to sum all missing values based on gender
But I get this output:
in which as you also notice, ALL row doesn't sum all missing values per gender.
Where is the problem in my code? Should I use another way to create the pivot table?
](https://i.sstatic.net/LKGk47dr.png)](https://mapledrawhubb.com/i.sstatic.net/fX7IWn6t.png)