Reputation: 452
Using the following dictionary:
dic = {'S1':["2013-11-12", "2013-11-13"],
'S2':["2013-11-15", "2013-11-17"]}
How can I create the following DataFrame with multiple column indices?
S1 S2
Start Stop Start Stop
2013-11-12 2013-11-13 2013-11-15 2013-11-17
Any help is appreciated.
Upvotes: 5
Views: 2706
Reputation: 14748
You could do this:
index = pd.MultiIndex.from_product([['S1', 'S2'], ['Start', 'Stop']])
print pd.DataFrame([pd.DataFrame(dic).unstack().values], columns=index)
Output:
S1 S2
Start Stop Start Stop
0 2013-11-12 2013-11-13 2013-11-15 2013-11-17
Upvotes: 6