I'm trying to add youtube thumbnail links to a dataframe with other youtube video data from an API.
pdr['thumbnail']=[]
pdr['url'] = pdr['url'].astype('string')
for index,rows in pdr.iterrows():
if i['videoId']:
exp = "^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#&?]*).*"
s = re.findall(exp,url)[0][-1]
thumbnail_url = f"https://i.ytimg.com/vi/{s}/maxresdefault.jpg"
thumbnail.append(thumbnail_url)
else:
thumbnail.append('nan')
I keep getting this error message:
ValueError: Length of values (0) does not match length of index (604)