application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
import matplotlib.pyplot as plt

import os

import pandas as pd

product_name_dictionary = {}
product_name_dictionary2 = {}
for dirname, _, filenames in os.walk('/kaggle/input/learnplatform-covid19-impact-on-digital-learning/engagement_data/'):
    for filename in filenames:
        engagement_data_path = os.path.join(dirname, filename)
        df_temp = pd.read_csv(engagement_data_path, dtype={'lp_id': str})
        df_temp = df_temp.fillna(0)
        df_temp = df_temp.groupby(by='lp_id', as_index=False).sum()
        for index, row in df_temp.iterrows():
            if row['lp_id'] in product_name_dictionary.keys():
                product_name_dictionary[row['lp_id']] += row['pct_access']
                product_name_dictionary2[row['lp_id']] += row['engagement_index']
            else:
                product_name_dictionary[row['lp_id']] = row['pct_access']
                product_name_dictionary2[row['lp_id']] = row['engagement_index']

def dict_val(x):
    return x[1]
sorted_product_name_dictionary = sorted(product_name_dictionary.items(), key=dict_val, reverse=True)

product_df = pd.read_csv('/kaggle/input/learnplatform-covid19-impact-on-digital-learning/products_info.csv', dtype={'LP ID': str})

i = 1
name_count = []
for key, val in sorted_product_name_dictionary[:11]:
    product_name = product_df[product_df['LP ID'] == key]['Product Name'].values
    if product_name != None:
        name_count.append((product_name[0], val))
        i += 1

name_count1 = pd.DataFrame([])
name_count1['products'] = [name[0] for name in name_count]
name_count1['percentage_of_access'] = [name[1] for name in name_count]

plt.figure(figsize=(20, 10))
plt.bar(name_count1['products'].values, name_count1['percentage_of_access'].values, color=['orange', 'blue'])
plt.xlabel('Top Product name')
plt.ylabel('Sum of percentage of access')
plt.show()