def _preprocess ( df ) : df = df . stack ( ) df . index . rename ( [ "id" , "time" ] , inplace = True ) # .reset_index() df . name = "value" df = df . reset_index ( ) return df
normalise python data frame multi column
given a DataFrame where records are stored row - wise rearrange it such that records are stored column - wise .
def _preprocess(df):
    """
    given a DataFrame where records are stored row-wise, rearrange it
    such that records are stored column-wise.
    """

    df = df.stack()

    df.index.rename(["id", "time"], inplace=True)  # .reset_index()
    df.name = "value"
    df = df.reset_index()

    return df