def spread(df, row_index, key):
    """
    Spread key-value pair to multiple columns

    Parameters
    ----------
    df : long format Dataframe
    row_index : transform to wide format row index column
    key : key column which return DataFrame column name

    Returns
    -------
    Pandas DataFrame
    """
    list_index = []
    if isinstance(row_index, list):
        list_index.extend(row_index)
    else:
        list_index.append(row_index)
    if isinstance(key, list):
        list_index.extend(key)
        list_key = key
    else:
        list_index.append(key)
        list_key = [key]
    df_return = df.set_index(list_index)
    if len(list_key) == 1:
        return df_return.unstack(-1)
    else:
        index_start = len(list_index) - len(list_key)
        index_end = len(list_index) - 1
        return df_return.unstack(list(range(index_start, index_end + 1)))
