# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] id="nX_W0YPqzyRc" colab_type="text"
# # Analysis of App Profiles for the App Store and Google Play Markets
#
# My aim in this project is to find mobile app profiles that are profitable for the App Store and Google Play markets. My job is to enable mobile app developers to make data-driven decisions with respect to the kind of apps they build.
#
# I will suppose that the main source of revenue consists of in-app ads. This means that the revenue for any given app is mostly influenced by the number of users that use the app. 
#
# My goal for this project is to analyze data to help developers understand what kinds of apps are likely to attract more users.

# + [markdown] id="nj3qhQSnzyRg" colab_type="text"
# ## Opening and Exploring the Data
#
# As of January 2020, there were approximately 2 million iOS apps available on the App Store, and 2.1 million Android apps on Google Play.
#
# Collecting data for over four million apps requires a significant amount of time and money, so we'll try to analyze a sample of data instead. To avoid spending resources with collecting new data ourselves, we should first try to see whether we can find any relevant existing data at no cost. Luckily, these are two data sets that seem suitable for our purpose:
#
# - [A data set](https://www.kaggle.com/lava18/google-play-store-apps) containing data about approximately ten thousand Android apps from Google Play. You can download the data set directly from [this link](https://dq-content.s3.amazonaws.com/350/googleplaystore.csv).
# - [A data set](https://www.kaggle.com/ramamet4/app-store-apple-data-set-10k-apps) containing data about approximately seven thousand iOS apps from the App Store. You can download the data set directly from [this link](https://dq-content.s3.amazonaws.com/350/AppleStore.csv).
#
# Let's start by opening the two data sets and then continue with exploring the data.

# + id="ZNzXBSALzyRl" colab_type="code" colab={}
from csv import reader

# Google Play dataset
with open("googleplaystore.csv") as f:
    android_data = list(reader(f))
# Apple Store dataset
with open("AppleStore.csv") as f:
    ios_data = list(reader(f))
    
android_cols = android_data[0]
android_data = android_data[1:]
ios_cols = ios_data[0]
ios_data = ios_data[1:]


# + [markdown] id="aVNUM6G2zyRr" colab_type="text"
# To make it easier to explore the two data sets, I'll first write a function named `explore_data()` that I can use repeatedly to explore rows in a more readable way. I'll also add an option for our function to show the number of rows and columns for any data set.

# + id="SiW2GuwezyRs" colab_type="code" colab={}
def explore_data(dataset, start, end, rows_and_columns=False):
    dataset_slice = dataset[start:end]    
    for row in dataset_slice:
        print(row)
        print('\n') # adds a new (empty) line after each row

    if rows_and_columns:
        print('Number of rows:', len(dataset))
        print('Number of columns:', len(dataset[0]))


# + [markdown] id="vTlm-FjczyRv" colab_type="text"
# Now let's take a look at the first few rows of each dataset.

# + id="FoMhUn5SzyRw" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 642} outputId="bde2d770-9092-4397-bb85-01a88a097fce"
n_rows = 3
print("First {} rows of the".format(n_rows), "Google Play Store", "dataset\n")
print(android_cols)
print("\n")
explore_data(android_data, 0, n_rows, True)
print("\n")
print("\n")
print("First {} rows of the".format(n_rows), "Apple Store", "dataset\n")
print(ios_cols)
print("\n")
explore_data(ios_data, 0, n_rows, True)


# + [markdown] id="UE3vWssczyR0" colab_type="text"
# The Google Play data set has 10841 apps and 13 columns. At a quick glance, the columns that might be useful for the purpose of our analysis are `'App'`, `'Category'`, `'Reviews'`, `'Installs'`, `'Type'`, `'Price'`, and `'Genres'`.
#
# We have 7197 iOS apps in this data set, and the columns that seem interesting are: `'track_name'`, `'currency'`, `'price'`, `'rating_count_tot'`, `'rating_count_ver'`, and `'prime_genre'`. Not all column names are self-explanatory in this case, but details about each column can be found in the data set [documentation](https://www.kaggle.com/ramamet4/app-store-apple-data-set-10k-apps/home).

# + [markdown] id="XEkJ769CzyR6" colab_type="text"
# ## Data Cleaning
#
# Now we need to process the data to make some analysis.
#
# ### Deleting Wrong Data
#
# I build a function called `clean_dataset()` to analyze row by row the data set and print an error when there is a missing element and eventually remove the row.

# + id="FrEFsxP_zyR7" colab_type="code" colab={}
def clean_dataset(data, clean=False):
    LEN_COL_DATA = len(data[0])
    LEN_DATA = len(data)
    for idx, row in enumerate(data):
        len_row = len(row)
        if len_row != LEN_COL_DATA:
            print("Row number", len_row, "contains missing values\n")
            if clean:
                del data[idx]
                print("Removed bad row\n")
    if LEN_DATA == len(data):
        print("No bad rows!\n")


# + [markdown] id="lt_Y-spPzyR-" colab_type="text"
# Now I'm looking on the entire data sets to see if there are some missing values.
#
#

# + id="egbI7oCjzyR_" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 218} outputId="c556537c-d207-443c-ca41-1507969a742d"
print("Google Play Store", "dataset\n")
clean_dataset(android_data, True)
print("\n")
print("Apple Store", "dataset\n")
clean_dataset(ios_data, True)


# + [markdown] id="ogtsjo0kzySC" colab_type="text"
# ### Removing Duplicate Entries
#
# Let's build a function called `duplicate_in_dataset()` to analyze row by row the data set and tell us if there are some duplicate rows.

# + id="auCVio7ZzySD" colab_type="code" colab={}
def duplicate_in_dataset(data, NAME_COL=0):
    duplicate_apps = []
    unique_apps = []
    for app in data:
        name = app[NAME_COL]
        if name in unique_apps:
            duplicate_apps.append(name)
        else:
            unique_apps.append(name)
    
    print("Number of duplicate apps:", len(duplicate_apps))
    print("\n")
    print("Examples of duplicate apps:", duplicate_apps[:15])


# + [markdown] id="Wk_wRbcyzySI" colab_type="text"
# For the *Google Play Store* the column that contains the name of the APP is *App* at index 0.
#
# For the *Apple Store* the column that contains the name of the APP is *track_name* at index 1.

# + id="IsGRT84FzySK" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 272} outputId="8a3e4202-d23a-46d3-f0ff-44fb940a48b4"
print("Google Play Store", "dataset\n")
duplicate_in_dataset(android_data, 0)
print("\n")
print("Apple Store", "dataset\n")
duplicate_in_dataset(ios_data, 1)


# + [markdown] id="t3T74HO0zySQ" colab_type="text"
# We don't want to count certain apps more than once when we analyze data, so we need to remove the duplicate entries and keep only one entry per app. One thing we could do is remove the duplicate rows randomly, but we could probably find a better way.
#
# The main difference happens on the number of reviews. The different numbers show that the data was collected at different times. We can use this to build a criterion for keeping rows. We won't remove rows randomly, but rather we'll keep the rows that have the highest number of reviews because the higher the number of reviews, the more reliable the ratings.
#
# To do that, we will:
#
# - Create a dictionary where each key is a unique app name, and the value is the highest number of reviews of that app
# - Use the dictionary to create a new data set, which will have only one entry per app (and we only select the apps with the highest number of reviews)
#
# Let's build a function `remove_duplicates()` to do this.

# + id="hH8yXBRpzySS" colab_type="code" colab={}
def remove_duplicates(data, NAME_COL, RATING_COL):
    # create an empty dict to store unique APPs rows
    dict_rows = {}
    for row in data:
        # save name and rating for next comparison
        name = row[NAME_COL]
        rating = float(row[RATING_COL])
        # if we don't have already a row for that app save it
        if name not in dict_rows:
            dict_rows[name] = row
        # else compare the rating stored to check if its greater
        elif rating > float(dict_rows[name][RATING_COL]):
            dict_rows[name] = row
            
    # finally merge all the rows stored as a new dataset
    data_new = list(dict_rows.values())
    return data_new


# + [markdown] id="nFzR0RTwzySV" colab_type="text"
# For the *Google Play Store* the column that contains the number of ratings of the APP is *Reviews* at index 3.
#
# For the *Apple Store* the column that contains the number of ratings of the APP is *rating_count_tot* at index 5.

# + id="bDYqAIqNzySW" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 185} outputId="d11e1bfd-a054-4544-e10e-77bdb1b0aa8c"
print("Google Play Store", "dataset\n")
android_clean = remove_duplicates(android_data, 0, 3)
print("Removed:", len(android_data) - len(android_clean),"rows\n")
print("\n")
print("Apple Store", "dataset\n")
ios_clean = remove_duplicates(ios_data, 1, 5)
print("Removed:", len(ios_data) - len(ios_clean),"rows\n")


# + [markdown] id="ioLk2sUSzySa" colab_type="text"
# ### Removing Non-English Apps
#
# If you explore the data sets enough, you'll notice the names of some of the apps suggest they are not directed toward an English-speaking audience.
#
# We're not interested in keeping these kind of apps, so we'll remove them. One way to go about this is to remove each app whose name contains a symbol that is not commonly used in English text — English text usually includes letters from the English alphabet, numbers composed of digits from 0 to 9, punctuation marks (., !, ?, ;, etc.), and other symbols (+, *, /, etc.).
#
# All these characters that are specific to English texts are encoded using the ASCII standard. Each ASCII character has a corresponding number between 0 and 127 associated with it, and we can take advantage of that to build a function `normal_string()` that checks an app name and tells us whether it contains non-ASCII characters more than a fixed thereshold.
#
# We built this function below, and we use the built-in `ord()` function to find out the corresponding encoding number of each character.

# + id="jxPW_xoVzySb" colab_type="code" colab={}
def normal_string(string, LIMIT=3):
    count = 0
    for a in string:
        if ord(a) > 127: # it is a non-English character
            count += 1
            if count > LIMIT:
                return False
    # if it has finished the for loop there aren't non-English characters
    return True


# + [markdown] id="I-II4VNuzySh" colab_type="text"
# Check the output of the function for some examples:

# + id="L2GadvB6zySi" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 84} outputId="ac32dbe4-fc9e-4201-db36-745465b01f16"
print(normal_string("Instagram"))
print(normal_string("爱奇艺PPS -《欢乐颂2》电视剧热播"))
print(normal_string("Docs To Go™ Free Office Suite"))
print(normal_string("Instachat 😜"))


# + [markdown] id="PdNcNamgzySl" colab_type="text"
# Let's build a function called `english_dataset()` to create a new dataset containing only English apps using the `normal_string()` function.

# + id="9C_eTjFezySm" colab_type="code" colab={}
def english_dataset(data, NAME_COL=0):
    data_new = []
    for row in data:
        name = row[NAME_COL]
        if normal_string(name):
            data_new.append(row)
    return data_new


# + [markdown] id="m9v22wUqzySp" colab_type="text"
# The function is still not perfect, and very few non-English apps might get past our filter, but this seems good enough at this point in our analysis — we shouldn't spend too much time on optimization at this point.
#
# Use the above new function `english_dataset()` to create new datasets.

# + id="eICu3tPYzySq" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 185} outputId="fe14dac4-743d-4b12-a978-ce57cd99ec6b"
print("Google Play Store", "dataset\n")
android_clean_english = english_dataset(android_clean, 0)
print("Removed:", len(android_clean) - len(android_clean_english),"non-English apps\n")
print("\n")
print("Apple Store", "dataset\n")
ios_clean_english = english_dataset(ios_clean, 1)
print("Removed:", len(ios_clean) - len(ios_clean_english),"non-English apps\n")


# + [markdown] id="ubJDzVmYzySt" colab_type="text"
# ### Isolating the Free Apps
#
# As we mentioned in the introduction, we only study apps that are free to download and install, and our main source of revenue consists of in-app ads. Our data sets contain both free and non-free apps, and we'll need to isolate only the free apps for our analysis. Below, we isolate the free apps for both our data sets.
#
# Let's build a function called `free_dataset()` to create a new dataset containing only free apps.

# + id="Q4G3kvKDzySv" colab_type="code" colab={}
def free_dataset(data, PRICE_COL):
    data_new = []
    for row in data:
        # check if the APP is free
        if row[PRICE_COL] == "0.0" or row[PRICE_COL] == "0":
            data_new.append(row)
    return data_new


# + [markdown] id="MEOLV7glzySy" colab_type="text"
# For the *Google Play Store* the column that contains the price of the APP is *Price* at index 7.
#
# For the *Apple Store* the column that contains the price of the APP is *price* at index 4.

# + id="j2KnyyQLzySz" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 185} outputId="6c9b128f-2a6a-4522-fe0c-723331963450"
print("Google Play Store", "dataset\n")
android_final = free_dataset(android_clean_english, 7)
print("Removed:", len(android_clean_english) - len(android_final),"paid apps\n")
print("\n")
print("Apple Store", "dataset\n")
ios_final = free_dataset(ios_clean_english, 4)
print("Removed:", len(ios_clean_english) - len(ios_final),"paid apps\n")

# + [markdown] id="4Uo4zeGdzyS2" colab_type="text"
# Final datasets:

# + id="gz5H5Hv7zyS2" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 507} outputId="0fa7acf6-690e-464a-f399-52fb6a2b4985"
print("First {} rows of the".format(n_rows), "Google Play Store", "dataset\n")
explore_data(android_final, 0, n_rows, True)
print("\n")
print("First {} rows of the".format(n_rows), "Apple Store", "dataset\n")
explore_data(ios_final, 0, n_rows, True)


# + [markdown] id="sOPAojtFzyS4" colab_type="text"
# ## Data Analysis
#

# + [markdown] id="aaAqbsA2Dtk7" colab_type="text"
# ### Most Common Apps by Genre
#
# As I mentioned in the introduction, my aim is to determine the kinds of apps that are likely to attract more users because our revenue is highly influenced by the number of people using the apps.
#
# To minimize risks and overhead, the validation strategy for an app idea is comprised of three steps:
#
# 1. Build a minimal Android version of the app, and add it to Google Play.
# 2. If the app has a good response from users, develop it further.
# 3. If the app is profitable after six months, also build an iOS version of the app and add it to the App Store.
#
# Because the end goal is to add the app on both the App Store and Google Play, we need to find app profiles that are successful on both markets. For instance, a profile that might work well for both markets might be a productivity app that makes use of gamification.
#
# Let's begin the analysis by getting a sense of the most common genres for each market. For this, we'll build a frequency table for the `prime_genre` column of the App Store data set, and the `Genres` and `Category` columns of the Google Play data set.
#
# I'll build two functions we can use to analyze the frequency tables:
#
# - One function to generate frequency tables that show percentages
# - Another function that we can use to display the percentages in a descending order

# + id="zTEHShVEzyS6" colab_type="code" colab={}
def freq_table(dataset, index):
    table = {}
    for row in dataset:
        val = row[index]
        if val in table:
            table[val] += 1
        else:
            table[val] = 1
    return table

def display_table(dataset, index):
    table = freq_table(dataset, index)
    table_display = []
    for key in table:
        key_val_as_tuple = (table[key], key)
        table_display.append(key_val_as_tuple)

    table_sorted = sorted(table_display, reverse = True)
    for entry in table_sorted:
        print(entry[1], ':', entry[0])


# + [markdown] id="QqaJpm9qDC9Y" colab_type="text"
# We start by examining the frequency table for the `prime_genre` column of the App Store data set.

# + id="jc1EmHq-zyS9" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 403} outputId="1ca7be5b-bdd0-480a-d1d8-1b546389e6b7"
display_table(ios_final, 11)

# + [markdown] id="XpGySRstDIJx" colab_type="text"
# We can see that among the free English apps, more than a half (58.16%) are games. Entertainment apps are close to 8%, followed by photo and video apps, which are close to 5%. Only 3.66% of the apps are designed for education, followed by social networking apps which amount for 3.29% of the apps in our data set. 
#
# The general impression is that App Store (at least the part containing free English apps) is dominated by apps that are designed for fun (games, entertainment, photo and video, social networking, sports, music, etc.), while apps with practical purposes (education, shopping, utilities, productivity, lifestyle, etc.) are more rare. However, the fact that fun apps are the most numerous doesn't also imply that they also have the greatest number of users — the demand might not be the same as the offer. 
#
# Let's continue by examining the `Genres` and `Category` columns of the Google Play data set (two columns which seem to be related).

# + id="V-pUsqpxzyTA" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 571} outputId="e93ce24c-6acd-46a4-f7f3-844937f8b252"
display_table(android_final, 1) # Category

# + [markdown] id="fCjmPqbkDQZD" colab_type="text"
# The landscape seems significantly different on Google Play: there are not that many apps designed for fun, and it seems that a good number of apps are designed for practical purposes (family, tools, business, lifestyle, productivity, etc.). However, if we investigate this further, we can see that the family category (which accounts for almost 19% of the apps) means mostly games for kids.
#
#
# Even so, practical apps seem to have a better representation on Google Play compared to App Store. This picture is also confirmed by the frequency table we see for the `Genres` column:

# + id="zXyPnGArzyTC" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 1000} outputId="4f67c657-403a-45de-a037-6a45faf9c68c"
display_table(android_final, 9) # Genres

# + [markdown] id="kqdqkNr9DbfE" colab_type="text"
# The difference between the `Genres` and the `Category` columns is not crystal clear, but one thing we can notice is that the `Genres` column is much more granular (it has more categories). We're only looking for the bigger picture at the moment, so we'll only work with the `Category` column moving forward.
#
# Up to this point, we found that the App Store is dominated by apps designed for fun, while Google Play shows a more balanced landscape of both practical and for-fun apps. Now we'd like to get an idea about the kind of apps that have most users.

# + [markdown] id="4itFZkw4DgM_" colab_type="text"
# ### Most Popular Apps by Genre on the App Store
#
# One way to find out what genres are the most popular (have the most users) is to calculate the average number of installs for each app genre. For the Google Play data set, we can find this information in the `Installs` column, but for the App Store data set this information is missing. As a workaround, we'll take the total number of user ratings as a proxy, which we can find in the `rating_count_tot` app.
#
# Below, we calculate the average number of user ratings per app genre on the App Store:

# + id="kGAYQ7O3zyTF" colab_type="code" colab={"base_uri": "https://localhost:8080/", "height": 403} outputId="32776e0f-ff26-4bef-d471-0455bee5735f"
ios_genre_freq_table = freq_table(ios_final, 11)

for genre in ios_genre_freq_table:
    total = 0
    len_genre = 0
    for row in ios_final:
        if row[11] == genre:
            total += float(row[5])
            len_genre += 1
    print(genre, ":", round(total/len_genre))

# + [markdown] id="VVlrDyBpD-H1" colab_type="text"
# On average, navigation apps have the highest number of user reviews, but this figure is heavily influenced by Waze and Google Maps, which have close to half a million user reviews together:

# + colab_type="code" id="rdNDNVbVdw4X" outputId="4d9f8744-a164-4ac0-a56c-ba8eb5ecf6f9" colab={"base_uri": "https://localhost:8080/", "height": 118}
for app in ios_final:
    if app[-5] == 'Navigation':
        print(app[1], ':', app[5]) # print name and number of ratings

# + [markdown] colab_type="text" id="55kQqN_qdw4Z"
# The same pattern applies to social networking apps, where the average number is heavily influenced by a few giants like Facebook, Pinterest, Skype, etc. Same applies to music apps, where a few big players like Pandora, Spotify, and Shazam heavily influence the average number.
#
# Our aim is to find popular genres, but navigation, social networking or music apps might seem more popular than they really are. The average number of ratings seem to be skewed by very few apps which have hundreds of thousands of user ratings, while the other apps may struggle to get past the 10,000 threshold. We could get a better picture by removing these extremely popular apps for each genre and then rework the averages, but we'll leave this level of detail for later.
#
# Reference apps have 74,942 user ratings on average, but it's actually the Bible and Dictionary.com which skew up the average rating:

# + colab_type="code" id="T2H7TxY6dw4a" outputId="7c81bbba-365c-47bc-e8cf-64beec498733" colab={"base_uri": "https://localhost:8080/", "height": 319}
for app in ios_final:
    if app[-5] == 'Reference':
        print(app[1], ':', app[5])

# + [markdown] colab_type="text" id="RClnbNGSdw4d"
# However, this niche seems to show some potential. One thing we could do is take another popular book and turn it into an app where we could add different features besides the raw version of the book. This might include daily quotes from the book, an audio version of the book, quizzes about the book, etc. On top of that, we could also embed a dictionary within the app, so users don't need to exit our app to look up words in an external app.
#
# This idea seems to fit well with the fact that the App Store is dominated by for-fun apps. This suggests the market might be a bit saturated with for-fun apps, which means a practical app might have more of a chance to stand out among the huge number of apps on the App Store.
#
# Other genres that seem popular include weather, book, food and drink, or finance. The book genre seem to overlap a bit with the app idea we described above, but the other genres don't seem too interesting to us:
#
# - Weather apps — people generally don't spend too much time in-app, and the chances of making profit from in-app adds are low. Also, getting reliable live weather data may require us to connect our apps to non-free APIs.
#
# - Food and drink — examples here include Starbucks, Dunkin' Donuts, McDonald's, etc. So making a popular food and drink app requires actual cooking and a delivery service, which is outside the scope of our company.
#
# - Finance apps — these apps involve banking, paying bills, money transfer, etc. Building a finance app requires domain knowledge, and we don't want to hire a finance expert just to build an app.
#
# Now let's analyze the Google Play market a bit.

# + [markdown] id="fkw_5EcKEM2p" colab_type="text"
# ### Most Popular Apps by Genre on Google Play
#
# For the Google Play market, we actually have data about the number of installs, so we should be able to get a clearer picture about genre popularity. However, the install numbers don't seem precise enough — we can see that most values are open-ended (100+, 1,000+, 5,000+, etc.):

# + colab_type="code" id="k9XN-3Oxdw4e" outputId="4c059bef-c6a1-4c8b-8be2-a65f8fb32676" colab={"base_uri": "https://localhost:8080/", "height": 370}
display_table(android_final, 5) # the Installs columns

# + [markdown] colab_type="text" id="MS8oEkvcdw4g"
# One problem with this data is that is not precise. For instance, we don't know whether an app with 100,000+ installs has 100,000 installs, 200,000, or 350,000. However, we don't need very precise data for our purposes — we only want to get an idea which app genres attract the most users, and we don't need perfect precision with respect to the number of users.
#
# We're going to leave the numbers as they are, which means that we'll consider that an app with 100,000+ installs has 100,000 installs, and an app with 1,000,000+ installs has 1,000,000 installs, and so on.
#
# To perform computations, however, we'll need to convert each install number to `float` — this means that we need to remove the commas and the plus characters, otherwise the conversion will fail and raise an error. We'll do this directly in the loop below, where we also compute the average number of installs for each genre (category).

# + colab_type="code" outputId="68579b74-d620-445b-eccb-8c66726673a7" id="RUs1BELB42qM" colab={"base_uri": "https://localhost:8080/", "height": 571}
android_category_freq_table = freq_table(android_final, 1)

for category in android_category_freq_table:
    total = 0
    len_category = 0
    for row in android_final:
        if row[1] == category:
            total += float(row[5].replace(",", "").replace("+", ""))
            len_category += 1
    print(category, ":", round(total/len_category))

# + [markdown] colab_type="text" id="jmJZ_ZNAdw4m"
# On average, communication apps have the most installs: 38,456,119. This number is heavily skewed up by a few apps that have over one billion installs (WhatsApp, Facebook Messenger, Skype, Google Chrome, Gmail, and Hangouts), and a few others with over 100 and 500 million installs:

# + colab_type="code" id="yDgqLB3xdw4p" outputId="8b5839ac-aac6-4396-85ff-4a816a258717" colab={"base_uri": "https://localhost:8080/", "height": 470}
for app in android_final:
    if app[1] == 'COMMUNICATION' and (app[5] == '1,000,000,000+'
                                      or app[5] == '500,000,000+'
                                      or app[5] == '100,000,000+'):
        print(app[0], ':', app[5])

# + [markdown] colab_type="text" id="GkB0Ewlsdw47"
# If we removed all the communication apps that have over 100 million installs, the average would be reduced roughly ten times:

# + colab_type="code" id="GVS8X24bdw48" outputId="0eaeadd0-c078-4f0b-fba5-a21dc4fb7d34" colab={"base_uri": "https://localhost:8080/", "height": 34}
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):
        under_100_m.append(float(n_installs))
        
sum(under_100_m) / len(under_100_m)

# + [markdown] colab_type="text" id="VGf0n6cydw5A"
# We see the same pattern for the video players category, which is the runner-up with 24,727,872 installs. The market is dominated by apps like Youtube, Google Play Movies & TV, or MX Player. The pattern is repeated for social apps (where we have giants like Facebook, Instagram, Google+, etc.), photography apps (Google Photos and other popular photo editors), or productivity apps (Microsoft Word, Dropbox, Google Calendar, Evernote, etc.).
#
# Again, the main concern is that these app genres might seem more popular than they really are. Moreover, these niches seem to be dominated by a few giants who are hard to compete against.
#
# The game genre seems pretty popular, but previously we found out this part of the market seems a bit saturated, so we'd like to come up with a different app recommendation if possible.
#
# The books and reference genre looks fairly popular as well, with an average number of installs of 8,767,811. It's interesting to explore this in more depth, since we found this genre has some potential to work well on the App Store, and our aim is to recommend an app genre that shows potential for being profitable on both the App Store and Google Play. 
#
# Let's take a look at some of the apps from this genre and their number of installs:

# + colab_type="code" id="EsjrE2Nudw5B" outputId="bc245ebd-ea99-4aaa-9f67-4fc94050f24b" colab={"base_uri": "https://localhost:8080/", "height": 1000}
for app in android_final:
    if app[1] == 'BOOKS_AND_REFERENCE':
        print(app[0], ':', app[5])

# + [markdown] colab_type="text" id="j4vZcL-Udw5G"
# The book and reference genre includes a variety of apps: software for processing and reading ebooks, various collections of libraries, dictionaries, tutorials on programming or languages, etc. It seems there's still a small number of extremely popular apps that skew the average:

# + colab_type="code" id="sPYrMGhKdw5H" outputId="95ec4ea1-8b98-422f-ec55-2dd7ad72cb20" colab={"base_uri": "https://localhost:8080/", "height": 101}
for app in android_final:
    if app[1] == 'BOOKS_AND_REFERENCE' and (app[5] == '1,000,000,000+'
                                            or app[5] == '500,000,000+'
                                            or app[5] == '100,000,000+'):
        print(app[0], ':', app[5])

# + [markdown] colab_type="text" id="jGuGD7ODdw5K"
# However, it looks like there are only a few very popular apps, so this market still shows potential. Let's try to get some app ideas based on the kind of apps that are somewhere in the middle in terms of popularity (between 1,000,000 and 100,000,000 downloads):

# + colab_type="code" id="s9pL6QCddw5K" outputId="c6b8fa6c-42a1-410a-b87c-c0d93dd3f0a8" colab={"base_uri": "https://localhost:8080/", "height": 823}
for app in android_final:
    if app[1] == 'BOOKS_AND_REFERENCE' and (app[5] == '1,000,000+'
                                            or app[5] == '5,000,000+'
                                            or app[5] == '10,000,000+'
                                            or app[5] == '50,000,000+'):
        print(app[0], ':', app[5])

# + [markdown] colab_type="text" id="MnArt0Mbdw5M"
# This niche seems to be dominated by software for processing and reading ebooks, as well as various collections of libraries and dictionaries, so it's probably not a good idea to build similar apps since there'll be some significant competition.
#
# We also notice there are quite a few apps built around the book Quran, which suggests that building an app around a popular book can be profitable. It seems that taking a popular book (perhaps a more recent book) and turning it into an app could be profitable for both the Google Play and the App Store markets.
#
# However, it looks like the market is already full of libraries, so we need to add some special features besides the raw version of the book. This might include daily quotes from the book, an audio version of the book, quizzes on the book, a forum where people can discuss the book, etc.

# + [markdown] id="VZcWb5Q7EvQp" colab_type="text"
# ## Conclusions
#
# In this project, we analyzed data about the App Store and Google Play mobile apps with the goal of recommending an app profile that can be profitable for both markets.
#
# We concluded that taking a popular book (perhaps a more recent book) and turning it into an app could be profitable for both the Google Play and the App Store markets. The markets are already full of libraries, so we need to add some special features besides the raw version of the book. This might include daily quotes from the book, an audio version of the book, quizzes on the book, a forum where people can discuss the book, etc.

StarcoderdataJupyterScriptsDedupFiltered