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

Time:10-14

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])

CodePudding user response:

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).

  • Related