I want to load multiple CSV files into one dataframe. Each CSV contains stock data with 6 columns ( 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume' ) . I managed to load the CSV files, but I'm missing the column name ( each ticker, from CSV ).
sp500 = os.listdir(os.path.splitext(os.getcwd()+'/spy500')[0])
combined = pd.concat([pd.read_csv('spy500/'+i, parse_dates=True, index_col='Date') for i in sp500], axis=1)
output:
Open | High |Low |Close| Adj Close |Volume| Open| High| Low Close| Adj Close |Volume
desire output:
AAPL | GOOG
Open |High |Low |Close |Adj Close |Volume |Open |High |Low |Close |Adj Close |Volume
the output is correct, the only thing I need is to add a multi level column: 5986 rows × 3030 columns