AmbiguousTimeError when trying to display dataframe with timestamps
See original GitHub issueSummary
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
- 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.
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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 withAmbiguousTimeError
since the arror dataframe serialization does not automatically convertdatetime
instances to other timezones. However, the legacy dataframe still has some unsolved issues with timezones which we do not plan to fix.