I have imported data into dataframe that looks like this
VMGI US Equity VMGI Open VMGI High VMGI Low VMGI Px_last VMGI Volume SPOM US Equity SPOM Open SPOM High SPOM Low SPOM Px_last SPOM Volume
Date
12/31/2012 12/31/2012 0.009 0.011 0.009 0.009 105726 12/31/2012 0.4575 0.4575 0.2925 0.3975 8890
1/1/2013 1/1/2013 0.009 0.011 0.009 0.009 105726 1/1/2013 0.4575 0.4575 0.2925 0.3975 8890
1/2/2013 1/2/2013 0.009 0.01 0.008 0.01 188150 1/2/2013 0.3975 0.3975 0.3225 0.3225 3400
1/3/2013 1/3/2013 0.011 0.018 0.011 0.015 169890 1/3/2013 0.34 0.3738 0.28 0.29 48933
1/4/2013 1/4/2013 0.015 0.018 0.014 0.018 33500 1/4/2013 0.36 0.4 0.3175 0.3175 3610
Each 6th column is a new stock. The rows go on for 1340 rows. I want to re-organize in a multi-index (I think) to create data that looks like this because I wanted to add additional columns for each stock. I was able to get the stock names with the following code
index2 =index1[0::6] >>> which results in an object as follows (the first column for each stock)
Index(['VMGI US Equity', 'SPOM US Equity', 'OPTL US Equity', 'FRHV US Equity', etc....
Ultimately I want the dataframe to look like a index with each stock
VMGI US Equity VMGI US Equity VMGI Open VMGI High VMGI Low VMGI Px_last VMGI Volume
12/31/2012 0.009 0.011 0.009 0.009 105726
1/1/2013 0.009 0.011 0.009 0.009 105726
1/2/2013 0.009 0.01 0.008 0.01 188150
1/3/2013 0.011 0.018 0.011 0.015 169890
1/4/2013 0.015 0.018 0.014 0.018 33500
SPOM US Equity SPOM US Equity SPOM Open SPOM High SPOM Low SPOM Px_last SPOM Volume
12/31/2012 0.4575 0.4575 0.2925 0.3975 8890
1/1/2013 0.4575 0.4575 0.2925 0.3975 8890
I have tried set_index and got the follow error.
df2.index = df_clean_penny1.set_index(index2)
ValueError: Length mismatch: Expected axis has 1340 elements, new values have 65 elements
From other posts I have also tried MultiIndex.from_arrays() but also could not get it to work. any help/guidance is appreciated