Dr Phil McGraw examines cases and talks about topics on psychology with his guests while he analyses them and offers tough solutions.
TV journalist Maury Povich -- yes, he began his TV career as a news anchor -- tackles volatile issues with his guests and studio audience on this daily, hourlong talk showy Show
Actress and comedian Ellen DeGeneres talks to celebrities and interacts with the audience in her own inimitable way, besides witnessing performances by comedic, musical and cinematic personalities.
The Real is an American syndicated talk show created by SallyAnn Salsano (495 Productions). The series initially received a trial run on Fox-owned markets ...
Host Trevor Noah delivers satirical news related to the international and American political matters in an entertaining way.e Daily Show
# lets import libraries
from googleapiclient.discovery import build
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Function to get Dr Phil Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Dr_Phil_channel_id = ['UCYLR1ghzYNyvfjw78raCuxA' # Dr Phil
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Dr_Phil_channel_id ):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Dr_Phil_channel_id )
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Dr_Phil_channel_id)
[{'Channel_name': 'Dr. Phil', 'Subscribers': '6230000', 'Views': '5732270246', 'Total_videos': '13740'}]
channel_statistics = get_channel_stats(youtube,Dr_Phil_channel_id)
Dr_Phil_channel_data =pd.DataFrame(channel_statistics)
Dr_Phil_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Dr. Phil | 6230000 | 5732270246 | 13740 |
# Function to get Maury Show Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
Maury_Show_channel_id = ['UCcoB7_8vWOW88GIFe_SXv6A' # Maury Show
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Maury_Show_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Maury_Show_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,Maury_Show_channel_id)
[{'Channel_name': 'Maury Show', 'Subscribers': '2090000', 'Views': '858042206', 'Total_videos': '3195'}]
channel_statistics = get_channel_stats(youtube,Maury_Show_channel_id )
Maury_Show_channel_data =pd.DataFrame(channel_statistics)
Maury_Show_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | Maury Show | 2090000 | 858042206 | 3195 |
# Function to get The Ellen Show Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
The_Ellen_Shown_channel_id = ['UCp0hYYBW6IMayGgR-WeoCvQ' # The Ellen Show
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube,The_Ellen_Shown_channel_id ):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(The_Ellen_Shown_channel_id )
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,The_Ellen_Shown_channel_id)
[{'Channel_name': 'TheEllenShow', 'Subscribers': '38200000', 'Views': '23009548755', 'Total_videos': '16371'}]
channel_statistics = get_channel_stats(youtube,The_Ellen_Shown_channel_id )
The_Ellen_Shown_channel_data =pd.DataFrame(channel_statistics)
The_Ellen_Shown_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | TheEllenShow | 38200000 | 23009548755 | 16371 |
# Function to get The Real Daytime Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
The_Real_channel_id = ['UCdM8C3ufiI-i-I1XSugKVvg' # The Real Daytime
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, Lex_Fridman_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(Lex_Fridman_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,The_Real_channel_id)
[{'Channel_name': 'The Real Daytime', 'Subscribers': '2420000', 'Views': '3347858707', 'Total_videos': '14541'}]
channel_statistics = get_channel_stats(youtube,The_Real_channel_id )
The_Real_channel_data =pd.DataFrame(channel_statistics)
The_Real_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | The Real Daytime | 2420000 | 3347858707 | 14541 |
# Function to get The Daily Show Youtube channel statistics
api_key = 'AIzaSyB24Kop04L1GlTgRCm1XtQ4KB2a4gaBOwA'
The_Daily_Show_channel_id = ['UCwWhs_6x42TyRM4Wstoq8HA' # The Daily Show
]
youtube = build('youtube','v3',developerKey = api_key)
from googleapiclient.errors import HttpError
def get_channel_stats(youtube, The_Daily_Show_channel_id):
all_data = []
try:
request = youtube.channels().list(
part='snippet,contentDetails,statistics',
id=','.join(The_Daily_Show_channel_id)
)
response = request.execute()
for item in response.get('items', []):
snippet = item.get('snippet', {})
statistics = item.get('statistics', {})
data = {
'Channel_name': snippet.get('title', ''),
'Subscribers': statistics.get('subscriberCount', ''),
'Views': statistics.get('viewCount', ''),
'Total_videos': statistics.get('videoCount', '')
}
all_data.append(data)
except HttpError as e:
print(f"HTTP error occurred: {e}")
print(f"Request URL: {e.resp.request.url}")
print(f"Request body: {e.resp.request.body}")
return all_data
get_channel_stats(youtube,The_Daily_Show_channel_id)
[{'Channel_name': 'The Daily Show', 'Subscribers': '10500000', 'Views': '5486732224', 'Total_videos': '5575'}]
channel_statistics = get_channel_stats(youtube,The_Daily_Show_channel_id)
The_Daily_Show_channel_data =pd.DataFrame(channel_statistics)
The_Daily_Show_channel_data
Channel_name | Subscribers | Views | Total_videos | |
---|---|---|---|---|
0 | The Daily Show | 10500000 | 5486732224 | 5575 |
# Combine DataFrames using concat
combined_talk_shows_channels_df = pd.concat([
Dr_Phil_channel_data ,
Maury_Show_channel_data,
The_Ellen_Shown_channel_data,
The_Real_channel_data ,
The_Daily_Show_channel_data,
], ignore_index=True)
# Display the result
print(combined_talk_shows_channels_df)
Channel_name Subscribers Views Total_videos 0 Dr. Phil 6230000 5732270246 13740 1 Maury Show 2090000 858042206 3195 2 TheEllenShow 38200000 23009548755 16371 3 The Real Daytime 2420000 3347858707 14541 4 The Daily Show 10500000 5486732224 5575
# lets change the datatypes to perform visualisations
combined_talk_shows_channels_df['Subscribers'] = pd.to_numeric(combined_talk_shows_channels_df['Subscribers'])
combined_talk_shows_channels_df['Views'] = pd.to_numeric(combined_talk_shows_channels_df['Views'])
combined_talk_shows_channels_df['Total_videos'] = pd.to_numeric(combined_talk_shows_channels_df['Total_videos'])
# letsconirm if the datatypes has changed
combined_talk_shows_channels_df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 5 entries, 0 to 4 Data columns (total 4 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 Channel_name 5 non-null object 1 Subscribers 5 non-null int64 2 Views 5 non-null int64 3 Total_videos 5 non-null int64 dtypes: int64(3), object(1) memory usage: 292.0+ bytes
import matplotlib.pyplot as plt
def plot_sorted_bar(df, column, color, ax):
# Sort the DataFrame by the specified column in descending order
df_sorted = df.sort_values(by=column, ascending=False)
# Plotting the bar chart
ax.bar(df_sorted['Channel_name'], df_sorted[column], color=color)
ax.set_title(column.capitalize()) # Set the title with the capitalized column name
# Sort and plot Subscribers
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(10, 15))
plot_sorted_bar(combined_talk_shows_channels_df, 'Subscribers', 'blue', axes[0])
# Sort and plot Views
plot_sorted_bar(combined_talk_shows_channels_df, 'Views', 'green', axes[1])
# Sort and plot Total Videos
plot_sorted_bar(combined_talk_shows_channels_df, 'Total_videos', 'orange', axes[2])
# Adjust layout for better visibility
plt.tight_layout()
# Show the plot
plt.show()