Incorrect Row Count: Removing Non English Apps Part 2

Screen Link:
https://app.dataquest.io/m/350/guided-project%3A-profitable-app-profiles-for-the-app-store-and-google-play-markets/7/removing-non-english-apps-part-two

My Code:

apple_eng = []
google_eng = []

for app in apps_apple_list:
    name = app[1]    
    if is_it_english(name):
        apple_eng.append(app) 


for app in android_clean:
    name = app[0]    
    if is_it_english(name):        
        google_eng.append(app)
  
explore_data(apple_eng, 0, 3, True)
explore_data(google_eng, 0, 3, True)

What I expected to happen:
The solution provides a row counts of 9614 Android apps and 6183 iOS apps.

What actually happened:

I get Number of rows: 7197 (for iOS)
I get Number of rows: 9659 (for Android)

['284882215', 'Facebook', '389879808', 'USD', '0.0', '2974676', '212', '3.5', '3.5', '95.0', '4+', 'Social Networking', '37', '1', '29', '1']


['389801252', 'Instagram', '113954816', 'USD', '0.0', '2161558', '1289', '4.5', '4.0', '10.23', '12+', 'Photo & Video', '37', '0', '29', '1']


['529479190', 'Clash of Clans', '116476928', 'USD', '0.0', '2130805', '579', '4.5', '4.5', '9.24.12', '9+', 'Games', '38', '5', '18', '1']


Number of rows: 7197
Number of columns: 16
['Photo Editor & Candy Camera & Grid & ScrapBook', 'ART_AND_DESIGN', '4.1', '159', '19M', '10,000+', 'Free', '0', 'Everyone', 'Art & Design', 'January 7, 2018', '1.0.0', '4.0.3 and up']


['U Launcher Lite – FREE Live Cool Themes, Hide Apps', 'ART_AND_DESIGN', '4.7', '87510', '8.7M', '5,000,000+', 'Free', '0', 'Everyone', 'Art & Design', 'August 1, 2018', '1.2.4', '4.0.3 and up']


['Sketch - Draw & Paint', 'ART_AND_DESIGN', '4.5', '215644', '25M', '50,000,000+', 'Free', '0', 'Teen', 'Art & Design', 'June 8, 2018', 'Varies with device', '4.2 and up']


Number of rows: 9659
Number of columns: 13

It appears that the non-ascii characters are not removed.

please also add is_it_english function code.

As per the solution I have two sections that have the same function. One builds on the other. Should I remove the first one?

def is_it_english(string_name):
    for character in string_name:
        if ord(character) > 127:
            return False
        
        return True
    
print(is_it_english('Instagram'))
print(is_it_english('爱奇艺PPS -《欢乐颂2》电视剧热播'))

def is_it_english(string_name):
    non_ascii = 0
    
    for character in string_name:
        if ord(character) > 127:
            non_ascii =+ 1
            
        if non_ascii > 3:
            return False
        else:
            return True
        
print(is_it_english('Docs To Go™ Free Office Suite'))
print(is_it_english('爱奇艺PPS -《欢乐颂2》电视剧热播 😜😜😜😜😜'))
1 Like

If your function exactly look like this then it is due logical error second if condition should be out of for loop scope.
like

def is_it_english(string_name):
    non_ascii = 0
    
    for character in string_name:
        if ord(character) > 127:
            non_ascii =+ 1
            
    if non_ascii > 3:
        return False
    else:
        return True

Try this it should work.

PS: For future if you post any code block then put in ``` tile surrounding signs. In the start and in the end of code block.

1 Like

Will put ``` around code in the future. I took your code and pasted it into the cell and clicked Run All and no change. Would it be possible for you to take a look at my code at the URL provided?

Share your notebook using this guidelines