how to make a dataframe from images python pandas

Yes, you can use pathlib to search for files like this.

Here’s an example of how to recursively search the current directory for .png files.

from pathlib import Path
image_dir_path = '.'

Then, you just need to reformat that into a dataframe. Here’s how to do that:

import pandas as pd
from pathlib import Path

image_dir_path = '.'
paths = [[-3:] for path in
df = pd.DataFrame(data=paths, columns=['Automaker', 'Model', 'Images'])

Note: you’ll probably need to change image_dir_path to the directory of images on your computer.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top