This is a multi-part question. I just can't seem to combine everything together. The goal is to to create one DataFrame (guessing using MultiIndex) that I can access as follows:
ticker = 'GOLD'
date = pd.to_datetime('1978/03/31')
current_bar = df.ix[ticker].ix[date]
Can I then just say: current_bar.Last ?
Anyway, here are the files, and how I load them.
In [108]: df = pd.read_csv('GOLD.csv', parse_dates='Date', index_col='Date')
In [109]: df
Out[109]:
Exp Last Volume
Date
1978-03-30 198002 995.6 54
1978-03-31 198002 999.5 78
In [110]: df2 = pd.read_csv('SPX.csv', parse_dates='Date', index_col='Date')
In [111]: df2
Out[111]:
Exp Last Volume
Date
1978-03-30 198003 215.5 25
1978-03-31 198003 214.1 99
Ideally, I want it to look like this (I think):
ticker GOLD SPX
values Exp Last Volume Exp Last Volume
Date
1978-03-30 198002 995.6 54 198003 215.5 25
1978-03-31 198002 999.5 78 198003 214.1 99
- I guess my questions are:
- How do I make this Hierarchical (the actual data has 20+ identical columns for each file)
- How do I then combine the files (I have about 100 that need to all go in 1 DataFrame)
- Is my assumption correct that I can then just do: current_bar.Last to get values?
Thanks so much.