YouTube Channels With Greatest Number of Trending Videos

By Elizabeth Kilpatrick, 01/17/2020

In [1]:
!pip install plotly
import pandas as pd
import plotly.express as px
Requirement already satisfied: plotly in /opt/conda/lib/python3.7/site-packages (4.4.1)
Requirement already satisfied: retrying>=1.3.3 in /opt/conda/lib/python3.7/site-packages (from plotly) (1.3.3)
Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from plotly) (1.13.0)
In [2]:
youtube_usa_frame = pd.read_csv('./USvideos.csv')
youtube_france_frame = pd.read_csv('./FRvideos.csv')
youtube_canada_frame = pd.read_csv('./CAvideos.csv')
youtube_britain_frame = pd.read_csv('./GBvideos.csv')
youtube_denmark_frame = pd.read_csv('./DEvideos.csv')
youtube_india_frame = pd.read_csv('./INvideos.csv')

youtube_usa_frame.insert(1, "country", "USA")
youtube_france_frame.insert(1, "country", "France")
youtube_canada_frame.insert(1, "country", "Canada")
youtube_britain_frame.insert(1, "country", "Great Britain")
youtube_denmark_frame.insert(1, "country", "Denmark")
youtube_india_frame.insert(1, "country", "India")

countries = [youtube_usa_frame, youtube_france_frame, youtube_canada_frame,
             youtube_britain_frame, youtube_denmark_frame, youtube_india_frame]

countries_frame = pd.concat(countries)

In the above cell, I am reading in the data from the csvs, putting them in 6 data frames, and then concatenating them into a large frame called countries_frame.

In [3]:
views_fig = px.scatter(countries_frame, x="publish_time", y="likes", color='country', 
                       title="Number of Likes On Trending YouTube Videos")
views_fig.update_layout(yaxis_title="Number of Likes")
views_fig.update_layout(xaxis_title="Publish Date")
views_fig.show()

The above graph shows the number of likes associated with each trending video in 6 countries. It is a test of the plotly package.

In [4]:
popular_youtube_channels = countries_frame["channel_title"].value_counts().head(50)
px.bar(x=popular_youtube_channels.index, y=popular_youtube_channels,
       title="YouTube Channels With the Greatest Number of Trending Videos in the United States", 
       labels=dict(x="", y="Total Number of Days the Channels' Videos Trended"))

The above chart shows the YouTube channels with the greatest number of trending videos in the United States. If the same video trended for more than one day, that was counted as separate occurances of trending.