Groupby giving back inf values

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

My Code: countries_mean = fcc_good.groupby(‘CountryLive’).mean()

countries_mean[‘money_spent_per_month’][[‘United States of America’,
‘India’, ‘United Kingdom’,
‘Canada’]]

I expect the code to return mean for the the specified countries. But the code is giving an output with inf values.

Output

CountryLive
United States of America inf
India inf
United Kingdom inf
Canada inf
Name: money_spent_per_month, dtype: float64

Using median or other aggregate functions is rendering the required output. But using other metrics apart from mean doesn’t really make sense in this scenario.

Any advise on this would be appreciated!

You should not expect that. value_counts return a Series containing counts of unique values. What you are doing is to create a series with mean for each value.

Yeah, my bad I mentioned value counts. I have corrected it now

1 Like

The issue has been resolved. there were some inf values in the data frame. Just had to get rid of them. Thanks though

1 Like