Pandas min() arg is an empty sequence error (boxplot question)

Question:

I tired to make a boxplot which shows ‘age’ boxplot of ‘unsurvived’ male and female data. There’re some of empty data in raw. But some of them still have their own data.
But it panadas shows ‘min() arg is an empty sequence’
How can I fix this problem?

sns.boxplot(x="Sex", y="Age", data=df[df["Survived"]]==0])
Asked By: Jiwon

||

Answers:

You are performing the filtering incorrectly. This should be:

sns.boxplot(x="Sex", y="Age", data=df[df["Survived"]==0])

If the error persists, ensure you have at least one row of data. You can check the output of:

df[df["Survived"]==0]

If you don’t have any rows, check the output of:

df["Survived"].unique()

And ensure 0 is present with the same type (eg. not '0' as string).

Answered By: mozway
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.