Hi guys,
I am trying to understand what is wrong with my code, and I have tried multiple things to make it work. So, as a last resort, I kindly ask for some help on how to debug the following code:
for i,second_values in enumerate(second_values):
url = f"https://www.googleapis.com/youtube/v3/videos?part=statistics,snippet&key={api_key}&id={i}"
data = json.loads(requests.get(url).text)
channel_id = data["items"][0]["snippet"]["channelId"]
published_date = data["items"][0]["snippet"]["publishedAt"]
video_title = data["items"][0]["snippet"]["title"]
video_description = data["items"][0]["snippet"]["description"]
likes = data["items"][0]["statistics"]["likeCount"]
dislikes = data["items"][0]["statistics"]["dislikeCount"]
views = data["items"][0]["statistics"]["viewCount"]
comment_count = data["items"][0]["statistics"]["commentCount"]
row = [video_id,channel_id,published_date,
video_title,video_description,
likes,dislikes,views,comment_count]
data_df.loc[i] = row
but I get this message:
IndexError: list index out of range
NB: everything works fine until cell 14, which I have copied and pasted above. Please, find the full code on the file below.
YouTube Channel - Player1.ipynb (80.4 KB)
Thank you so much!!