How to display a dataframe with one field through an altair chart?

Viewed 200

I have a dataframe, of this kind, I don't quite understand how to display it in the form of a regular curve graph.

enter image description here


    st.write(data_I)

    model_graph = alt.Chart(data_I).transform_filter(
        size
    ).mark_line().encode(
        x=alt.X('index'),
        y=alt.Y('confirmed:Q',  title='Колличество'),
    ).properties(
        width=820,
        height=500
    ).configure_axis(
        labelFontSize=17,
        titleFontSize=20
    )
    st.altair_chart(model_graph)

Accordingly, I do not understand what to indicate on the X axis

1 Answers

See the Including Index Data in the Altair docs; briefly, you can start with

alt.Chart(data_I.reset_index())

and then the index will be accessible as a normal dataframe column.

Related