Plotting line chart in local time zone

Hello, is the issue resolved?

My dataframe is in local timezone but when I plot the data using st.linechart(). Data is plotted automatically in the UTC timezone even though I have converted the data to local time zone.

Is the problem in my code or streamlit only plots using the UTC timezone automatically irrespective of the timezone info in dataframe.

Thanks in advance!
Suraj Jat

1 Like

Hi @Suraj_Bhanu_Jat,

Thanks for sharing this question!

Streamlit, by default, uses Vega Lite for plotting which displays time data in UTC regardless if timezone info in dataframe.

In your case, since you are using st.line_chart, Streamlit’s default behavior is to plot the data in UTC if it detects date values. You have a couple of options to resolve this. One is by manually adjusting the timezone within your data so that Vega Lite won’t interpret it as a date value and convert it to UTC.

Please share your code if this does not help resolve the issue.

Hello,

Thanks for your revert.

I am getting the data in UTC format from data source, But I want to plot it in UTC-4 time zone

I have manually changed the data frame to UTC-4 time zone. But when I am plotting the same converted data frame, it is getting plotted in UTC time zone.

You have to remove the tz information after the conversion.

1 Like

So basically I am fetching data from an API, and I am getting the data in UTC format from API.

So this is the function to fetch the data.

image

I want to give the start and end date in the function. Below is the code for date selection.
image
Here I want to select the date such that start date is automatically in UTC-4 format. For example if I want data from midnight i should be able to select the date such that it gives me the data on the basis of local time zone but not UTC.

Thanks for your suggestion:)

Can someone please help me with the query?

Suraj
On a side note what extension u use to display the lines for indentation.
Thanks
Sai

Sorry, I am a newbie in coding. are you asking for a code editor? I am using visualstudio.