Conditional Plots - Titanic data set is longer than expected

https://app.dataquest.io/m/152/conditional-plots/2/introduction-to-the-data-set

I’m using the below code to read in the titanic data set.

import pandas as pd

titanic = pd.read_csv("train.csv")

titanic = titanic.loc[:,["Survived","Pclass","Sex","Age","SibSp","Parch","Fare","Embarked"]]

titanic.dropna()

I get an error that states the dataset is longer than expected. The output shows 712 rows x 8 columns, but the variable explorer shows 891 rows x 8 columns. When the I run the code from “see the answer” it doesn’t throw any error. Can someone tell me if I’m doing anything wrong or is it just a DQ error?


hi @tiwari.ishaan24

Welcome to DQ Community!

thanks for posting your code as well and not a screenshot of code. :slight_smile:

you have not re-assigned the dataframe while coding dropna. So it is showing you the results of dropna but the dataframe hasn’t truly been effected by the method.

1 Like