I have a question in regards to using pd.read_csv I am currently building a dataframe from multiple csv files from a folder and the csv files are named as follows: "C2__1979H" or "C2_1999Z"
I would like to set the index of my dataFrame to equal the name of the CSV file it is currently pulling to create my dataframe. I have yet to find a way to do that. Here is my current code
my dataframe looks like this:
Date Open High Low Close Vol OI Roll
0 19780106 236.00 237.50 234.50 235.50 0 0 0
1 19780113 235.50 239.00 235.00 238.25 0 0 0
2 19780120 238.00 239.00 234.50 237.00 0 0 0
3 19780127 237.00 238.50 235.50 236.00 0 0 0
I want it to look like this
Date Open High Low Close Vol OI Roll
C2__1979N 19780106 236.00 237.50 234.50 235.50 0 0 0
C2__1979N 19780113 235.50 239.00 235.00 238.25 0 0 0
C2__1979N 19780120 238.00 239.00 234.50 237.00 0 0 0
C2__1979Z 19780127 237.00 238.50 235.50 236.00 0 0 0 ##(assuming this is where the next csv file began)