Reputation: 11
I have the links in the column but I am trying to convert them to images
thumbnails = []
for index,row in pdr.iterrows():
s = row['videoId']
thumbnail_url = f"https://i.ytimg.com/vi/{s}/maxresdefault.jpg"
thumbnails.append(thumbnail_url)
pdr['thumbnail'] = thumbnails
This is the output. I am trying to fill the 'thumbnail' column with images as opposed to linked text.
Upvotes: 1
Views: 1376
Reputation: 3289
from IPython.display import Image
Image(url= "http://my_site.com/my_picture.jpg")
Upvotes: 0
Reputation: 3987
Try this:
thumbnails = []
for index,row in pdr.iterrows():
s = row['videoId']
thumbnail_url = f"<img src='https://i.ytimg.com/vi/{s}/maxresdefault.jpg' width='100px'>"
thumbnails.append(thumbnail_url)
pdr['thumbnail'] = thumbnails
We have created the DataFrame, now we have to show it:
from IPython.display import Image, HTML
HTML(df.to_html(escape=False))
This will show you the DataFrame with real image rather then only link.
Learn more from here:
Upvotes: 1