Different result and getting error: "remove_na is deprecated and is a private function. Do not use" when using seaborn

Screen Link:

https://app.dataquest.io/c/56/m/310/guided-project%3A-finding-the-best-markets-to-advertise-in/5/spending-money-for-learning

My Code:

country_list=["United States of America", "India", "United Kingdom", "Canada"]

filtered_survey=survey[survey["CountryLive"].isin(country_list)]
filtered_survey["MonthsProgramming"].replace(0,1, inplace=True)
country_spending_table=filtered_survey[["CountryLive","MoneyForLearning", "MonthsProgramming"]]
country_spending_table=country_spending_table[country_spending_table["MonthsProgramming"].notnull()]
country_spending_table=country_spending_table[country_spending_table["CountryLive"].notnull()]
country_spending_table=country_spending_table[country_spending_table["MoneyForLearning"].notnull()]
country_spending_table["MoneyPerMonth"]=country_spending_table["MoneyForLearning"]/country_spending_table["MonthsProgramming"]
country_spending_table.groupby(["CountryLive"], sort=True)["MoneyPerMonth"].mean()

import seaborn as sns
sns.boxplot(y="MoneyPerMonth", x= "CountryLive", data=country_spending_table)
plt.title("MOney Spent Per Month Per Country\(n) (Distribution)", fontsize=16)
plt.show()

What I expected to happen:

What actually happened:

CountryLive
Canada                      118.434054
India                        66.526198
United Kingdom               55.774980
United States of America    206.297711
Name: MoneyPerMonth, dtype: float64

/dataquest/system/env/python3/lib/python3.4/site-packages/seaborn/categorical.py:454: FutureWarning:

remove_na is deprecated and is a private function. Do not use.

My code is break down in these steps:

  • Filter data that has only 4 countries: US, UK, India, Canada
  • Replace the value of column “MonthsProgramming” if it is 0 to 1
  • Create new dataframe that has 3 columns: “CountryLive”, “MoneyForLearning” and “MonthsProgramming”
  • Drop null value
  • Create one more column name “MoneyPerMonth” for money that people spent per month for learning
  • Using groupby to calculate the mean of money per month for 4 countries.

When I compare result to the solution of DQ, they are different (money per month per country)
When I using seaborn to show boxplot to see the outlier, it shows error:
"/dataquest/system/env/python3/lib/python3.4/site-packages/seaborn/categorical.py:454: FutureWarning:

remove_na is deprecated and is a private function. Do not use."

I dont know if I did something wrong, can anyone have a look and point out what I missed or misunderstood the instruction or code?

Many thanks in advance.

That’s not an error. It states that it’s a warning (FutureWarning) and that can be ignored. In a future version of seaborn (compared to the one used by DQ right now), remove_na won’t be available and it won’t work hence the warning.

Your code seems to run fine and you get the plot as expected. If you don’t get the plot at all, then there’s some other issue in the rest of your code. Because I ran your code above in my implementation and I got the same plot.

1 Like

Thank you. I’ve tried in my local computer and it does not show the error when using seaborn
Can you pls have a look for the first issue of mine? I have different result than DQ’s solution. Many thanks.

CountryLive
Canada 118.434054
India 66.526198
United Kingdom 55.774980
United States of America 206.297711
Name: MoneyPerMonth, dtype: float64

The values that you are comparing to in the DQ solution are calculated after removing outliers which is the next step of the project.

Thank you for your reply my 2nd question.
For the first one, I’ve reviewed my code and found out that I’ve missed some filtering data at first place. I have just corrected it and now my output is same as DQ’s solution result.