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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With