# Calculation returns as "nan"

My Code:

``````androids_tot_rate_categ = {}
for row in free_uniq_Eng_androids[1:]: #free_uniq_Eng_androids is my cleaned dataset
category = row[1]
rating = float(row[2])
if category in androids_tot_rate_categ:
androids_tot_rate_categ[category] += rating
else:
androids_tot_rate_categ[category] = rating
print(androids_tot_rate_categ)
print('\n')

androids_avg_rate_categ = {}

for category in androids_tot_rate_categ:
androids_avg_rate_categ[category] = androids_tot_rate_categ[category]/androids_categories_pop[category]

print(androids_avg_rate_categ)

``````

Hi, I was doing Guided Project #1 (Profitable app trends) and I just got to analyzing the dataset after cleaning it.

I messed around and managed to show ‘Number of apps per category’ and ‘Number of reviews per category’. I thought that I would also find the ‘Average rating per category’ by dividing ‘Total rating per category’ with ‘Number of apps per category’.

However, the resulted shows that each category returns to “nan” ( which I assume to be “Not a Number”), except for the “Entertainment” category (which is pretty weird from my limited understanding).

``````Average rating per category:
{'ART_AND_DESIGN': nan, 'AUTO_AND_VEHICLES': nan, 'BEAUTY': nan, 'BOOKS_AND_REFERENCE': nan, 'BUSINESS': nan, 'COMICS': nan, 'COMMUNICATION': nan, 'DATING': nan, 'EDUCATION': nan, 'ENTERTAINMENT': 350.0999999999999, 'EVENTS': nan, 'FINANCE': nan, 'FOOD_AND_DRINK': nan, 'HEALTH_AND_FITNESS': nan, 'HOUSE_AND_HOME': nan, 'LIBRARIES_AND_DEMO': nan, 'LIFESTYLE': nan, 'GAME': nan, 'FAMILY': nan, 'MEDICAL': nan, 'SOCIAL': nan, 'SHOPPING': nan, 'PHOTOGRAPHY': nan, 'SPORTS': nan, 'TRAVEL_AND_LOCAL': nan, 'TOOLS': nan, 'PERSONALIZATION': nan, 'PRODUCTIVITY': nan, 'PARENTING': nan, 'WEATHER': nan, 'VIDEO_PLAYERS': nan, 'NEWS_AND_MAGAZINES': nan, 'MAPS_AND_NAVIGATION': nan}

{'ART_AND_DESIGN': nan, 'AUTO_AND_VEHICLES': nan, 'BEAUTY': nan, 'BOOKS_AND_REFERENCE': nan, 'BUSINESS': nan, 'COMICS': nan, 'COMMUNICATION': nan, 'DATING': nan, 'EDUCATION': nan, 'ENTERTAINMENT': 4.118823529411763, 'EVENTS': nan, 'FINANCE': nan, 'FOOD_AND_DRINK': nan, 'HEALTH_AND_FITNESS': nan, 'HOUSE_AND_HOME': nan, 'LIBRARIES_AND_DEMO': nan, 'LIFESTYLE': nan, 'GAME': nan, 'FAMILY': nan, 'MEDICAL': nan, 'SOCIAL': nan, 'SHOPPING': nan, 'PHOTOGRAPHY': nan, 'SPORTS': nan, 'TRAVEL_AND_LOCAL': nan, 'TOOLS': nan, 'PERSONALIZATION': nan, 'PRODUCTIVITY': nan, 'PARENTING': nan, 'WEATHER': nan, 'VIDEO_PLAYERS': nan, 'NEWS_AND_MAGAZINES': nan, 'MAPS_AND_NAVIGATION': nan}
``````