Guided project - profitable apps - 350-10 - frequency table returning same percentage for every

Screen Link:

https://app.dataquest.io/c/112/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/10/most-common-apps-by-genre-part-two

My Code:

applebycategory = {}
androidbygenre = {}
androidbycategory = {}


def freq_table(dataset,index):
    newfreqtable = {}
    total = 0
    
    for row in dataset:
        total += 1
        category = row[index]
        if category in dataset:
            newfreqtable[category] += 1
        else:
            newfreqtable[category] = 1
       
    morphtopercentages = {}
    
    for entry in newfreqtable:
        
        morphtopercentages[entry] = newfreqtable[entry] / total * 100
            
    return morphtopercentages
            
applebycategory = freq_table(freeapple,11)
androidbycategory = freq_table(freeandroid,1)
androidbygenre = freq_table(freeandroid,9)

print(applebycategory)
print(androidbycategory)
print(androidbygenre)```

What I expected to happen:

Returns percentages by category

What actually happened: 

{‘Social Networking’: 0.031036623215394164, ‘Photo & Video’: 0.031036623215394164, ‘Games’: 0.031036623215394164, ‘Music’: 0.031036623215394164, ‘Reference’: 0.031036623215394164, ‘Health & Fitness’: 0.031036623215394164, ‘Weather’: 0.031036623215394164, ‘Utilities’: 0.031036623215394164, ‘Travel’: 0.031036623215394164, ‘Shopping’: 0.031036623215394164, ‘News’: 0.031036623215394164, ‘Navigation’: 0.031036623215394164, ‘Lifestyle’: 0.031036623215394164, ‘Entertainment’: 0.031036623215394164, ‘Food & Drink’: 0.031036623215394164, ‘Sports’: 0.031036623215394164, ‘Book’: 0.031036623215394164, ‘Finance’: 0.031036623215394164, ‘Education’: 0.031036623215394164, ‘Productivity’: 0.031036623215394164, ‘Business’: 0.031036623215394164, ‘Catalogs’: 0.031036623215394164, ‘Medical’: 0.031036623215394164}
{‘ART_AND_DESIGN’: 0.01128158844765343, ‘AUTO_AND_VEHICLES’: 0.01128158844765343, ‘BEAUTY’: 0.01128158844765343, ‘BOOKS_AND_REFERENCE’: 0.01128158844765343, ‘BUSINESS’: 0.01128158844765343, ‘COMICS’: 0.01128158844765343, ‘COMMUNICATION’: 0.01128158844765343, ‘DATING’: 0.01128158844765343, ‘EDUCATION’: 0.01128158844765343, ‘ENTERTAINMENT’: 0.01128158844765343, ‘EVENTS’: 0.01128158844765343, ‘FINANCE’: 0.01128158844765343, ‘FOOD_AND_DRINK’: 0.01128158844765343, ‘HEALTH_AND_FITNESS’: 0.01128158844765343, ‘HOUSE_AND_HOME’: 0.01128158844765343, ‘LIBRARIES_AND_DEMO’: 0.01128158844765343, ‘LIFESTYLE’: 0.01128158844765343, ‘GAME’: 0.01128158844765343, ‘FAMILY’: 0.01128158844765343, ‘MEDICAL’: 0.01128158844765343, ‘SOCIAL’: 0.01128158844765343, ‘SHOPPING’: 0.01128158844765343, ‘PHOTOGRAPHY’: 0.01128158844765343, ‘SPORTS’: 0.01128158844765343, ‘TRAVEL_AND_LOCAL’: 0.01128158844765343, ‘TOOLS’: 0.01128158844765343, ‘PERSONALIZATION’: 0.01128158844765343, ‘PRODUCTIVITY’: 0.01128158844765343, ‘PARENTING’: 0.01128158844765343, ‘WEATHER’: 0.01128158844765343, ‘VIDEO_PLAYERS’: 0.01128158844765343, ‘NEWS_AND_MAGAZINES’: 0.01128158844765343, ‘MAPS_AND_NAVIGATION’: 0.01128158844765343}
{‘Art & Design’: 0.01128158844765343, ‘Art & Design;Creativity’: 0.01128158844765343, ‘Auto & Vehicles’: 0.01128158844765343, ‘Beauty’: 0.01128158844765343, ‘Books & Reference’: 0.01128158844765343, ‘Business’: 0.01128158844765343, ‘Comics’: 0.01128158844765343, ‘Comics;Creativity’: 0.01128158844765343, ‘Communication’: 0.01128158844765343, ‘Dating’: 0.01128158844765343, ‘Education’: 0.01128158844765343, ‘Education;Creativity’: 0.01128158844765343, ‘Education;Education’: 0.01128158844765343, ‘Education;Pretend Play’: 0.01128158844765343, ‘Education;Brain Games’: 0.01128158844765343, ‘Entertainment’: 0.01128158844765343, ‘Entertainment;Brain Games’: 0.01128158844765343, ‘Entertainment;Creativity’: 0.01128158844765343, ‘Entertainment;Music & Video’: 0.01128158844765343, ‘Events’: 0.01128158844765343, ‘Finance’: 0.01128158844765343, ‘Food & Drink’: 0.01128158844765343, ‘Health & Fitness’: 0.01128158844765343, ‘House & Home’: 0.01128158844765343, ‘Libraries & Demo’: 0.01128158844765343, ‘Lifestyle’: 0.01128158844765343, ‘Lifestyle;Pretend Play’: 0.01128158844765343, ‘Card’: 0.01128158844765343, ‘Arcade’: 0.01128158844765343, ‘Puzzle’: 0.01128158844765343, ‘Racing’: 0.01128158844765343, ‘Sports’: 0.01128158844765343, ‘Casual’: 0.01128158844765343, ‘Simulation’: 0.01128158844765343, ‘Adventure’: 0.01128158844765343, ‘Trivia’: 0.01128158844765343, ‘Action’: 0.01128158844765343, ‘Word’: 0.01128158844765343, ‘Role Playing’: 0.01128158844765343, ‘Strategy’: 0.01128158844765343, ‘Board’: 0.01128158844765343, ‘Music’: 0.01128158844765343, ‘Action;Action & Adventure’: 0.01128158844765343, ‘Casual;Brain Games’: 0.01128158844765343, ‘Educational;Creativity’: 0.01128158844765343, ‘Puzzle;Brain Games’: 0.01128158844765343, ‘Educational;Education’: 0.01128158844765343, ‘Casual;Pretend Play’: 0.01128158844765343, ‘Educational;Brain Games’: 0.01128158844765343, ‘Art & Design;Pretend Play’: 0.01128158844765343, ‘Educational;Pretend Play’: 0.01128158844765343, ‘Entertainment;Education’: 0.01128158844765343, ‘Casual;Education’: 0.01128158844765343, ‘Casual;Creativity’: 0.01128158844765343, ‘Casual;Action & Adventure’: 0.01128158844765343, ‘Music;Music & Video’: 0.01128158844765343, ‘Arcade;Pretend Play’: 0.01128158844765343, ‘Adventure;Action & Adventure’: 0.01128158844765343, ‘Role Playing;Action & Adventure’: 0.01128158844765343, ‘Simulation;Pretend Play’: 0.01128158844765343, ‘Puzzle;Creativity’: 0.01128158844765343, ‘Simulation;Action & Adventure’: 0.01128158844765343, ‘Racing;Action & Adventure’: 0.01128158844765343, ‘Sports;Action & Adventure’: 0.01128158844765343, ‘Educational;Action & Adventure’: 0.01128158844765343, ‘Arcade;Action & Adventure’: 0.01128158844765343, ‘Entertainment;Action & Adventure’: 0.01128158844765343, ‘Art & Design;Action & Adventure’: 0.01128158844765343, ‘Puzzle;Action & Adventure’: 0.01128158844765343, ‘Education;Action & Adventure’: 0.01128158844765343, ‘Strategy;Action & Adventure’: 0.01128158844765343, ‘Music & Audio;Music & Video’: 0.01128158844765343, ‘Health & Fitness;Education’: 0.01128158844765343, ‘Board;Action & Adventure’: 0.01128158844765343, ‘Board;Brain Games’: 0.01128158844765343, ‘Casual;Music & Video’: 0.01128158844765343, ‘Education;Music & Video’: 0.01128158844765343, ‘Role Playing;Pretend Play’: 0.01128158844765343, ‘Entertainment;Pretend Play’: 0.01128158844765343, ‘Medical’: 0.01128158844765343, ‘Social’: 0.01128158844765343, ‘Shopping’: 0.01128158844765343, ‘Photography’: 0.01128158844765343, ‘Travel & Local’: 0.01128158844765343, ‘Travel & Local;Action & Adventure’: 0.01128158844765343, ‘Tools’: 0.01128158844765343, ‘Tools;Education’: 0.01128158844765343, ‘Personalization’: 0.01128158844765343, ‘Productivity’: 0.01128158844765343, ‘Parenting’: 0.01128158844765343, ‘Parenting;Music & Video’: 0.01128158844765343, ‘Parenting;Education’: 0.01128158844765343, ‘Parenting;Brain Games’: 0.01128158844765343, ‘Weather’: 0.01128158844765343, ‘Video Players & Editors’: 0.01128158844765343, ‘Video Players & Editors;Music & Video’: 0.01128158844765343, ‘Video Players & Editors;Creativity’: 0.01128158844765343, ‘News & Magazines’: 0.01128158844765343, ‘Maps & Navigation’: 0.01128158844765343, ‘Health & Fitness;Action & Adventure’: 0.01128158844765343, ‘Educational’: 0.01128158844765343, ‘Casino’: 0.01128158844765343, ‘Trivia;Education’: 0.01128158844765343, ‘Lifestyle;Education’: 0.01128158844765343, ‘Card;Action & Adventure’: 0.01128158844765343, ‘Books & Reference;Education’: 0.01128158844765343, ‘Simulation;Education’: 0.01128158844765343, ‘Puzzle;Education’: 0.01128158844765343, ‘Adventure;Education’: 0.01128158844765343, ‘Role Playing;Brain Games’: 0.01128158844765343, ‘Strategy;Education’: 0.01128158844765343, ‘Racing;Pretend Play’: 0.01128158844765343, ‘Communication;Creativity’: 0.01128158844765343, ‘Strategy;Creativity’: 0.01128158844765343}```

For each call of the function, the output for each function is exactly the same and a number much smaller than expected

I figured it out. I should be using a boolean to check if the category is in the newfreqtable, not the data set. Corrected code:

‘’’
applebycategory = {}
androidbygenre = {}
androidbycategory = {}

def freq_table(dataset,index):
newfreqtable = {}
total = 0

for row in dataset:
    total += 1
    category = row[index]
    if category in newfreqtable:
        newfreqtable[category] += 1
    else:
        newfreqtable[category] = 1
   
morphtopercentages = {}

for entry in newfreqtable:
    
    morphtopercentages[entry] = newfreqtable[entry] / total * 100
        
return morphtopercentages

‘’’