def _maybe_melt_data_for_add_rows(data, delta_type, last_index):
    import pandas as pd
    import streamlit.elements.data_frame_proto as data_frame_proto
    if (delta_type in DELTAS_TYPES_THAT_MELT_DATAFRAMES):
        if (not isinstance(data, pd.DataFrame)):
            data = type_util.convert_anything_to_df(data)
        if (type(data.index) is pd.RangeIndex):
            old_step = _get_pandas_index_attr(data, 'step')
            data = data.reset_index(drop=True)
            old_stop = _get_pandas_index_attr(data, 'stop')
            if ((old_step is None) or (old_stop is None)):
                raise StreamlitAPIException("'RangeIndex' object has no attribute 'step'")
            start = (last_index + old_step)
            stop = ((last_index + old_step) + old_stop)
            data.index = pd.RangeIndex(start=start, stop=stop, step=old_step)
            last_index = (stop - 1)
        index_name = data.index.name
        if (index_name is None):
            index_name = 'index'
        data = pd.melt(data.reset_index(), id_vars=[index_name])
    return (data, last_index)
def _maybe_melt_data_for_add_rows(data, delta_type, last_index):
    import pandas as pd
    import streamlit.elements.data_frame_proto as data_frame_proto
    if (delta_type in DELTAS_TYPES_THAT_MELT_DATAFRAMES):
        if (not isinstance(data, pd.DataFrame)):
            data = type_util.convert_anything_to_df(data)
        if (type(data.index) is pd.RangeIndex):
            old_step = _get_pandas_index_attr(data, 'step')
            data = data.reset_index(drop=True)
            old_stop = _get_pandas_index_attr(data, 'stop')
            if ((old_step is None) or (old_stop is None)):
                raise StreamlitAPIException("'RangeIndex' object has no attribute 'step'")
            start = (last_index + old_step)
            stop = ((last_index + old_step) + old_stop)
            data.index = pd.RangeIndex(start=start, stop=stop, step=old_step)
            last_index = (stop - 1)
        index_name = data.index.name
        if (index_name is None):
            index_name = 'index'
        data = pd.melt(data.reset_index(), id_vars=[index_name])
    return (data, last_index)