I have a large number of png files where each filename is a unique ID with a corresponding data in a large pandas Dataframe. I can find the filenames by os.list and then try to find the corresponfin "ind = df['image_id']==name". However, this is a very slow process. Is there a more efficient approach?
import os
files = os.listdir(path)
for file in files:
name = file.split(".")[0]
index = df['image_id']==name
print(df.loc[index].values[0][1])