question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AmbiguousTimeError when trying to display dataframe with timestamps

See original GitHub issue

Summary

I get a the following error when trying to display a dataframe with datetime values: AmbiguousTimeError: Cannot infer dst time from %r, try using the 'ambiguous' argument

Steps to reproduce

  1. Have a panda dataframe with a column Series with datetime stamps over the whole year, so including the daylight saving time times and winter times.
  2. st.dataframe(df)

Expected behavior:

Display the dataframe with the time series in the Streamlit app.

Actual behavior:

Probably there ia a timestamp in there that is ambigious, like 2019-27-10 2:30 when the time shifted from 3.00 back to 2:00, so the system might not be sure when the actual timestamp is. The error AmbiguousTimeError: Cannot infer dst time from %r, try using the 'ambiguous' argument is thrown.

Is this a regression?

No

Debug info

  • Streamlit version: 0.57.2
  • Python version: 3.8.1
  • Using Conda? PipEnv? PyEnv? Pex? No
  • OS version: Mac 10.14.6
  • Browser version: Chrome 80.0.3987.149

Additional information

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
breycommented, Apr 21, 2020

Hi All, I am having the same problem when trying to display an Altair graph with time series that uses naive dates as x axis. I get the same error output as above. The graph is displayed nicely on Jupyterlab.

0reactions
LukasMasuchcommented, Feb 2, 2022

Closing this issue since timezone handling in dataframes was fixed with the change to arrow in Streamlit version 0.85. This also fixes the problem with AmbiguousTimeError since the arror dataframe serialization does not automatically convert datetime instances to other timezones. However, the legacy dataframe still has some unsolved issues with timezones which we do not plan to fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Doesn't Pandas Produce an Ambiguous Time Error?
In this code: ts1 = pd.Timestamp(no_such_time, tz=est) ts2 = pd.Timestamp(ambiguous_time, tz=est). pandas will convert both of these times ...
Read more >
pandas.Series.dt.tz_localize — pandas 1.5.2 documentation
'infer' will attempt to infer fall dst-transition hours based on order ... 'raise' will raise an AmbiguousTimeError if there are ambiguous times.
Read more >
pandas.DataFrame.tz_localize — pandas 1.5.2 documentation
'raise' will raise an AmbiguousTimeError if there are ambiguous times. nonexistentstr, default 'raise'. A nonexistent time does not exist in a particular ...
Read more >
Time series / date functionality — pandas 1.5.2 documentation
AmbiguousTimeError (the default behavior). 'infer' : Attempt to determine the correct offset base on the monotonicity of the timestamps. ' ...
Read more >
pandas.Timestamp.floor — pandas 1.5.2 documentation
'raise' will raise an AmbiguousTimeError for an ambiguous time. nonexistent{'raise', 'shift_forward', 'shift_backward, 'NaT', timedelta}, default 'raise'.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found