I have the following pandas.Dataframe
:
data = {'Timestamp': [12, 22],
'bmw-series1-exhaust': [0.1, 0.5],
'vw-series1-breaking': [0.7, 0.1],
'vw-series2-breaking': [0.2, 0.5]}
df = pd.DataFrame(data)
For the column name transformation I use the simple function (for now):
def to_customer_series(column_name):
return column_name.split('-')
I would like to split this dataframe into a new one with a multi-index of levels timestamp, customer and series:
I'm currently stuck on how to transform the dataframe. Would I first need to create a new 3-level nested dictionary (I tried this, SO link) out of the split data? or is there some way to use the built-in pandas functions to achieve this?
Any help is appreciated!