text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

df = pd.read_csv('../input/youtube-new/USvideos.csv')

cnt_video_per_category = df.groupby(['category_id']).count().reset_index()
cnt_video_per_category = cnt_video_per_category.loc[:, ['category_id', 'video_id']]
df_1 = pd.merge(cnt_video_per_category, category_df, left_on='category_id', right_on='category_id', how='left')
df_1 = df_1.sort_values(by='video_id', ascending=False)
df_1['Proportion'] = round(df_1['video_id'] / sum(df_1['video_id']) * 100, 2)
print(df_1)
sns.set(style='whitegrid')
plt.figure(figsize=(11, 10))
ax = sns.barplot(x='category_name', y='video_id', data=df_1)
ax.set_xticklabels(ax.get_xticklabels(), rotation=40, ha='right')
plt.tight_layout()
plt.show()