I can see the question mark (?) on most of your faces. Because even I had one before discovering that we can also render images inside a dataframe. And believe me, it’s simple and easy, all you need to know is to create a dataframe and I’ll pick you up from there.


Steps to be followed

  1. Import two necessary libraries such as **pandas**and **HTML**.
  2. Create a pandas dataframe of your choice and store it in the variable **df**.
  3. Create a list called **country** and then store all the paths of the images that you want to render.
  4. Assign the **country**list to the existing dataframe **df**. This would be appended as a new column to the existing dataframe.
  5. Write a function that will convert the given path of the images to the HTML tag.
  6. Render the dataframe as an HTML table, and then call the HTML method to display the rendered images.

Bonus


Code

Follow the above steps 1–6 to successfully render the images inside a dataframe. I will also be repeating the steps here too. You don’t have to scroll up to read every time.

Import two necessary libraries such as **pandas** and **HTML**.

The reason for importing **pandas** library is for creating and storing the data in a dataframe. Similarly, **HTML** library is used to render the image (HTML tags) inside a dataframe.

# Importing the necessary libraries

import pandas as pd
from IPython.core.display import HTML

_There is no need to manually install using _**_pip_**_ command, just importing it will serve the purpose_

#data-science #programming #image #python #pandas

Rendering Images inside a Pandas DataFrame
6.05 GEEK