Screen Link:
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.