I am trying to create a dataframe with filepaths as index:
import os
import pandas as pd
pathnames = []
for i in range(5):
pathnames.append(os.path.join('a',str(i)))
print(pathnames)
df = pd.DataFrame(index = pathnames)
df[pathnames[0]]
When using this example I get a key-error as pathnames[0]
is interpreted as a\\0
(as when printed) but not as a\0
. I expect the problem to be hidden in the raw string formatting.
Can someone explain and help?
pandas version tested: 0.24.2 and 1.1.0