w3resource

Pandas Pivot Titanic: Check missing values of children

Pandas: Pivot Titanic Exercise-17 with Solution

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.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://198.211.115.131/python-exercises/pandas/excel/pandas-pivot-titanic-exercise-17.php