428-13 Most Popular Apps by Genre on Google Play

Here is a screenshot and code below for my error.

The code is directly from the solution. So looks like until the inner loop finds a matching genre record, the total remains zero.

Also the way it’s formatted that total is always referring to the outer scope total = 0? When avg_installs = total / len_category is run it does not have access to the total += float(n_installs) in the if statement?

I tried to use an if statement:

if total > 0:
    avg_installs = total / len_category
    print(category, ':', avg_installs)

But same issue w/ scope, it looks like. Any workaround/clues? Thanks.

android_category = freq_table(android_final, 2)

for category in android_category:
    total = 0 #running total of each category/genre
    len_category = 0 #starts at zero and adds 1 for each genre in nested loop finds against outer genre

    for app in android_final:
        category_app = app[1]
        if category_app == category:
            n_installs = app[5] #save num of installs
            n_installs = n_installs.str.replace('+','') #remove string characters and convert to float
            n_installs = n_installs.str.replace(',','')
            total += float(n_installs) #add converted n_installs variable to total
            len_category += 1 #increment length of category by 1

    avg_installs = total / len_category
    print(category, ':', avg_installs)

Hey there!

The code itself looks sound — is there any way you can save a copy of your GP as an .ipynb file and shoot that over? Alternatively, you can just click the download button above your notebook and shoot the entire .tar file over if that’s easier.


1 Like

Wasn’t sure how to save the google csv file as .ipynb, but here is the notebook saved as such. Thanks!

Profitable_Apps_Project.py (14.1 KB)

Hi, I think your issue is with:

I’ve just looked at the data headings for the Play store data:
['App', 'Category', 'Rating', 'Reviews', 'Size', 'Installs', 'Type', 'Price', 'Content Rating', 'Genres', 'Last Updated', 'Current Ver', 'Android Ver']

‘Category’ is the 2nd column, so you would need to use 1 instead of 2, i.e

android_category = freq_table(android_final, 1)

Let us know if that works.

1 Like

Ah yes, Austin. That worked.

I’m not sure why I originally used index 2 instead of 1, but of course upon checking the CSV file the index was indeed 1.

Thanks for that.

1 Like

Please i am have issues with analysing Most users on google play by genre. Each time I run the block of code, I get an error, that string cannot be converted to float, I have gone through my code several times and every thing seems accurate.

under_100_m = [ ]

for app in android_final:
n_installs = app[5]
n_installs = n_installs.replace( ",", " ")
n_installs = n_installs.replace("+", " ")
if (app[1] == ‘COMMUNICATION’) and (float(n_installs) < 100000000):

sum(under_100_m) / len(under_100_m)

A ML developer can help to solve the problem.

Please, I urgently need help on this