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.

BUG: Regression - AmbiguousTimeError creating DataFrame

See original GitHub issue
  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

Pandas 1.25:

import pandas as pd
dt = pd.to_datetime('2019-11-03 01:00:00-0700').tz_convert('America/Los_Angeles')
pd.DataFrame({'dt': dt, 'value': [1]})
#                          dt  value
# 0 2019-11-03 01:00:00-07:00      1

Pandas 1.3:

import pandas as pd
dt = pd.to_datetime('2019-11-03 01:00:00-0700').tz_convert('America/Los_Angeles')
pd.DataFrame({'dt': dt, 'value': [1]})

#  File "pandas/_libs/tslibs/tzconversion.pyx", line 284, in pandas._libs.tslibs.tzconversion.tz_localize_to_utc
# pytz.exceptions.AmbiguousTimeError: Cannot infer dst time from 2019-11-03 01:00:00, try using the 'ambiguous' argument

Problem description

The dt object already has a timezone attribute, so it shouldn’t be converting/inferring at all.

Expected Output

1.25 and 1.3.0 should have the same output.

Output of pd.show_versions()

INSTALLED VERSIONS

commit : f00ed8f47020034e752baf0250483053340971b0 python : 3.7.3.final.0 python-bits : 64 OS : Darwin OS-release : 20.5.0 Version : Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8

pandas : 1.3.0 numpy : 1.21.0 pytz : 2021.1 dateutil : 2.8.1 pip : 21.1.2 setuptools : 57.0.0 Cython : None pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : 2.9.1 (dt dec pq3 ext lo64) jinja2 : None IPython : None pandas_datareader: None bs4 : None bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : 3.2.2 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : None pyxlsb : None s3fs : None scipy : 1.7.0 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None numba : None

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:14 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
rhshadrachcommented, Jul 13, 2021

@mzeitlin11 - I think standard practice is to cc the author of a PR where a regression has (or may have) occurred.

cc @jbrockmendel

0reactions
jbrockmendelcommented, Nov 18, 2021

Best guess remains sequence_to_dt64ns (https://github.com/pandas-dev/pandas/issues/42505#issuecomment-881730012). i’ll try to confirm this guess today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's New — pandas 0.23.3 documentation - PyData |
This is a minor bug-fix release in the 0.23.x series and includes some small regression fixes and bug fixes. We recommend that all...
Read more >
What's New — pandas 0.19.2 documentation
Fixed regression in DataFrame.quantile when missing values where present in some ... Bug in .set_index raises AmbiguousTimeError if new index contains DST ...
Read more >
Regression Testing | Techniques, Examples, Tips & More
' The software giants had no option but to backdate and fix the bug. When you do this (or release an update), you...
Read more >
Run regression analysis on multiple subsets of pandas ...
Based on the help I got here, I've been able to put together a function that takes all columns in a pandas dataframe,...
Read more >
RegMiner: Towards Constructing a Large Regression Dataset ...
In this work, we propose an approach to automate the process of harvesting replicable regression bugs from the code evolution history. We focus ......
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