The main columns headers will be Dates like 22-June, 23-June, 24-June. Each of these dates will have two sub columns Named "High" and "Low". Now there will be high value and low value in High column and Low column for each Date column. Please advice
1 Answer
You can use from_product when creating a MultiIndex.
dates = ['2016-1-1', '2016-1-2', '2016-1-3']
cols = pd.MultiIndex.from_product([dates, ['High', 'Low']])
>>> pd.DataFrame(np.random.randn(1,6), columns=cols)
2016-1-1 2016-1-2 2016-1-3
High Low High Low High Low
0 -0.075206 0.464617 0.347055 -0.807486 0.871124 -0.375196
2 Comments
user3117282
Thanks a ton. It was a great help as I am new to pandas and was not aware of MultiIndex feature
Henrique Amaral
What About I want a custom date for each case? I cant do product