w3resource

Pandas Pivot Titanic: Check missing values of children


Write a Pandas program to create a Pivot table and check missing values of children. Go to Editor

Sample Solution:

Python Code :

import pandas as pd
import numpy as np
df = pd.read_csv('titanic.csv')
result = df.loc[df['who']=='child'].isnull().sum()
print(result)

Sample Output:

survived        0
pclass          0
sex             0
age             0
sibsp           0
parch           0
fare            0
embarked        0
class           0
who             0
adult_male      0
deck           70
embark_town     0
alive           0
alone           0
Unnamed: 15    83
dtype: int64        

Python Code Editor:


Pivot Titanic.csv:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Pandas program to create a Pivot table and find number of adult male, adult female and children.
Next: Write a Pandas program to create a Pivot table and separate the gender according to whether they traveled alone or not to get the probability of survival.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.