At.linechart showing wrong date ( prev date from start date)

Hi,

I am having weird issue , line chart shows the date on label Jan 14, but my data starts from Jan 15

I am using , streamlit → 1.22 version

Hi @rshah25

It would also be helpful to also share the code snippet or GitHub repo to the app. The date select widget is indeed showing date at a later point in time from what is displayed in the plot. It may have been due to some subsequent processing, which can be figured out from looking at the code.

Hi @dataprofessor

sql = f"""
          select date(created_at) as Appointment_Date, count(*) as Total
    from table
    group by date(created_at)
    order by date(created_at)

     """

data = session.sql(sql).collect()
chart_pandas_df = pd.DataFrame(data,columns=["Appointment_Date","Total"])


r2col1,r2col2 = st.columns([3,4])
with r2col1:
    #STEP 6: SHOW UNDERLYING DATA
    st.subheader("Underlying Data")
    st.dataframe(data=chart_pandas_df)

with r2col2:
    #st.subheader("")
    st.line_chart(chart_pandas_df,x="Appointment_Date",y="Total")

This is very simple code.
Jan 14 2024 is showing up , it should be Jan 15 2024

Hi @rshah25

This is more of a data wrangling issue.

You could use Pandas’ unique() method to retrieve a list of unique values of the Appointment_date column and then use slicing to select a subset of data so that it starts from the next unique value (Jan 15, 2024) from the minimum value (Jan 14, 2024).

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.