0

I have a csv file that contains hundreds of images path and text file path with different extensions. Now i want to find the unique extension of these images and text files. How do i do that? eg of data contained in csv file:

images_path:

https://img.sportstars.id/2021/07/h4bc44/master_B7Nrz3845M_1077.JPG               
https://img.sportstars.id/2021/04/M17c3d/master_04fdj7Zi27_1560.jpg               
https://img.sportstars.id/2021/07/j6KY90/master_9uYf5T2Y97_1940.jpg

text_path:

xNeW1g.txt
YnENun.txt
tstaxy.txt

Note: both text and image path are contained in same csv as column names. Please any help would be appreciated. Thanks

Tranbi
  • 11,407
  • 6
  • 16
  • 33
Moon
  • 21
  • 5
  • 1
    In addition to @Tranbi solution, you can do: `df['images_extensions'] = df.images_path.apply(lambda x: os.path.splitext(x)[-1])` and then to get all the unique extensions: `df.images_extensions.unique()` – tzinie Nov 08 '21 at 09:53
  • Finally, found the solution. Thanks to both of you – Moon Nov 08 '21 at 11:28

1 Answers1

1

Use @tzinie's solution:

df['images_extensions'] = df['images_path'].apply(lambda x: os.path.splitext(x)[-1])