def add_text_label_from_index(df):
    text = []
    for idx in df.index:

        row_text = ''

        if isinstance(idx, tuple):
            # the lowest, non-empty index is the label
            for lev in reversed(idx):
                if lev is not '' and row_text == '':
                    row_text = str(lev)
        else:
            row_text = str(idx)

        text.append(row_text)

    df['text'] = text

    return df
Add column for text label, based on level-oriented index.
dataset/ETHPy150Open bokeh/bokeh/bokeh/charts/utils.py/add_text_label_from_index