Act fast, special offers end soon! Up to $294 is savings when you get Premium today.
Get offer codes

Drop rows by index Question

Hi guys,

I try to use my own way to detect Non-English Apps in Guided Project: Profitable App Profiles for the App Store and Google Play Markets.

First, I try to detect Apps name in Arabic language:

arabic_name = [  ]
for n in ios_df['track_name']:
    if re.findall("[\u0600-\u06FF]", n):
        arabic = ios_df.loc[ios_df['track_name'] == n]
        arabic_name.append(n)
print(arabic_name)

arabic_name : [‘Dictionary ( قاموس عربي / انجليزي + ودجيت الترجمة)’, ‘لغز الماضي - اربع اجزاء’]

Then, I try to get the row index which contains the Arabic names and drop the rows:

for name in arabic_name:
    display(ios_df.loc[ios_df['track_name']==name])
    indexNames = ios_df[ios_df['track_name'] == name].index.values
    print(indexNames)
    ios_df = ios_df.drop(index=ios_df.index[indexNames])

Result - IndexNames & Apps Names:
[2512 Dictionary ( قاموس عربي / انجليزي + ودجيت التر…],
[5797 لغز الماضي - اربع اجزاء]

Then, I run below code again to check if Arabic Apps still exist in the dataframe:

arabic_name = [  ]
for n in ios_df['track_name']:
    if re.findall("[\u0600-\u06FF]", n):
        arabic = ios_df.loc[ios_df['track_name'] == n]
        arabic_name.append(n)
print(arabic_name)

However, the Arabic App [‘لغز الماضي - اربع اجزاء’] still exists in the dataframe but the [2512 Dictionary ( قاموس عربي / انجليزي + ودجيت التر…] is dropped. Is it because after dropping [2512 Dictionary ( قاموس عربي / انجليزي + ودجيت التر…], the index of the df has changed, so [‘لغز الماضي - اربع اجزاء’] is longer 5797 indexed? If yes, how should I adjust the code to drop both Arabic Apps with correct indexes?

Thank you!

Please make sure that you are following the guidelines as mentioned in this post - Guidelines for asking a technical question in our Community. Especially guidelines 1 and 5.