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

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

youtube_df.columns

youtube_df.shape[0]

youtube = youtube_df[['video_id', 'title', 'channel_title', 'category_id', 'views', 'likes', 'dislikes']]

avg_views = round(youtube['views'].mean())
avg_views

condition = youtube[youtube.views >= avg_views].shape[0]
round(condition / youtube.shape[0] * 100)

# for the sake of being concise, we've directly modified the matplotlib object returned by the .plot() method
# you could plot these two scatter plots separately and still see the relationship!
ax1 = youtube.plot(kind='scatter', x='views', y='likes', color='g')   # likes are in green 
ax2 = youtube.plot(kind='scatter', x='views', y='dislikes', color='r', ax=ax1) # dislikes are in red
ax2.set_ylabel('viewer interactions (likes/dislikes)')

youtube.groupby('title')['views', 'sentiment'].mean().sort_values('views', ascending=False).head()

total_views = youtube.groupby('category_id')['views'].sum().sort_values(ascending=False).head(10)
total_views.plot.barh()

average_views = youtube.groupby('category_id')['views'].mean().sort_values(ascending=False).head(10)
average_views.plot.barh()