Skip to content
Advertisement

Tag: os.path

make os.listdir() list complete paths

Consider the following piece of code: The objective is to sort the listed files based on the creation time. However since the the os.listdir gives only the filename and not the absolute path the key ie, the os.path.getctime throws an exception saying OSError: [Errno 2] No such file or directory: ‘very_important_file.txt’ Is there a workaround to this situation or do

How to extract base path from DataFrame column of path strings

There are several questions about string manipulation, but I can’t find an answer which allows me to do the following—I thought it should have been simple… I have a DataFrame which includes a column containing a filename and path The following produces a representative example DataFrame: I want to end up with just the ‘filename’ part of the string. There

Advertisement