-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
BUG: pandas.to_datetime
raises exception when more than 50 values needs coercion to NaT
#43732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
hmm try this on master |
this is still failing on master |
The exception is raised on line 467 in array_to_datetime in tslib.pyx It raises the exception because (four lines above) the value of The value is So when |
take |
…ds coercion to NaT (pandas-dev#43732) Raise proper error from objects_to_datetime64ns Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
…ds coercion to NaT (pandas-dev#43732) Raise proper error from objects_to_datetime64ns Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
…ds coercion to NaT (pandas-dev#43732) Raise proper error from objects_to_datetime64ns Check for OutOfBoundsDatetime in _maybe_cache Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
…ds coercion to NaT (pandas-dev#43732) Raise proper error from objects_to_datetime64ns Check for OutOfBoundsDatetime in _maybe_cache Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
…ds coercion to NaT (pandas-dev#43732) Raise proper error from objects_to_datetime64ns Check for OutOfBoundsDatetime in _maybe_cache Co-authored-by: André Elimelek de Weber (andrekwr) <[email protected]> Co-authored-by: Henry Rocha (HenryRocha) <[email protected]>
I believe that this is a duplicated issue that was fixed during the closing of #45319, so this issue can be closed, right? |
this works fine on master now |
agreed, this was fixed and tested in the other issue |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the master branch of pandas.
Reproducible Example
Issue Description
Background (irrelevant for reproducing the bug, but good to know):
A google bigquery gives me dataframe with a column with datetime values with year=9999,
and I store the result as a parquet file. When I read it back,
read_parquet
crashes.I traced it down to the following problem in pd.to_datetime.
The issue:
if pd.datetime needs to convert more than 50 datetime values with tzinfo set, and those values are above year 2262 (the maximal date for pd.Timestamp) and should be coerced into NaT, then pd.to_datetime crashes with a raised exception. It works fine if the series is smaller than 51 items.
Expected Behavior
The expected behavior is that pd.to_datetime should return a list of NaT values also for Sequences longer than 50 items.
Installed Versions
commit : 73c6825
python : 3.7.10.final.0
python-bits : 64
OS : Linux
OS-release : 4.19.0-17-cloud-amd64
Version : #1 SMP Debian 4.19.194-3 (2021-07-18)
machine : x86_64
processor :
byteorder : little
LC_ALL : en_US.UTF-8
LANG : C.UTF-8
LOCALE : None.None
pandas : 1.3.3
numpy : 1.19.5
pytz : 2021.1
dateutil : 2.8.2
pip : 21.2.4
setuptools : 58.0.4
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.3
IPython : 7.27.0
pandas_datareader: None
bs4 : None
bottleneck : 1.3.2
fsspec : 2021.08.1
fastparquet : None
gcsfs : 2021.08.1
matplotlib : 3.4.3
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 5.0.0
pyxlsb : None
s3fs : None
scipy : 1.7.1
sqlalchemy : 1.4.25
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : 0.54.0
The text was updated successfully, but these errors were encountered: