1

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

Output: Code Output

This is the output. I am trying to fill the 'thumbnail' column with images as opposed to linked text.

2 Answers2

1

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:

Xitiz
  • 3,548
  • 1
  • 7
  • 30
0
from IPython.display import Image


Image(url= "http://my_site.com/my_picture.jpg")
aaossa
  • 3,468
  • 2
  • 19
  • 33
jeffasante
  • 481
  • 5
  • 6