Search code examples
pandasmulti-indexsktime

How to correctly format a pd-multiindex for sktime?


I have a pd.multiindex which looks like this: enter image description here

However, when I use the run check_raise(df_train, mtype="pd-multiindex)"

I get the following error:

File /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/sktime/datatypes/_check.py:252, in check_raise(obj, mtype, scitype, var_name) 250 return True 251 else: --> 252 raise TypeError(msg)

TypeError: input.loc[i] must be Series of mtype pd.DataFrame, not at i=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]

I believe this means I am meant to convert each row into a pandas series, but I am unsure if this is correct?

Any help would be appreciated.


Solution

  • I have similar issue, try to check if your index have duplicate keys, in your case:

    df_train.reset_index(['sbj', 'system_time_stamp'])[['sbj', 'system_time_stamp']].duplicated(keep=False)
    

    Remove duplicated index works for me.