-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
REGR: fillna on datetime64[ns, UTC] column hits RecursionError #38851
Comments
Note that dropping the from datetime import datetime, timezone
import pandas as pd
df = pd.DataFrame(range(31))
df["dt"] = pd.date_range("2020/12/01", "2020/12/31", tz="UTC")
df["dt"].iloc[5] = pd.NaT
df["dt"] = df["dt"].fillna(datetime(1980, 1, 1)) |
Thanks @akrherz for the report
first bad commit: [58f7468] CLN: remove unnecessary DatetimeTZBlock.fillna (#37040) cc @jbrockmendel |
Working on a fix for this. The tricky part is what to do when we have two different UTC dtypes.
Because the tzs dont match (#23959) and we dont allow setting mismatched tzs into DatetimeArray (#37605), we cast to a common dtype before trying again. But since the dtypes are considered equal, that dtype is unchanged, so we get a RecursionError. So three options for how to fix this: 1) change tz_compare, 2) change DatetimeArray's setitem behavior, or 3) change I lean towards option 1 |
Thanks @jbrockmendel for investigating this. We will want to backport a fix, so won't want any changes of behaviour. The commit that broke the old behaviour was a clean-up, so option 4 is we could revert and thereafter, reapply to master with any fix that changes behaviour deferred to 1.3. |
works for me |
@jbrockmendel could you do the revert as a short-term fix? For the long term:
Looking at the discussion in #37605, it seems we might want to change the setitem behaviour, so that could be a reason to go for 2) ? Now, fixing |
Code Sample
Problem description
pandas 1.2.0 is throwing a RecursionError while attempting to
fillna
on adatetime64[ns, UTC]
column. Same code worked in prior releases.Expected Output
Output of
pd.show_versions()
pd.show_versions()
/opt/miniconda3/envs/prod/lib/python3.8/site-packages/_distutils_hack/init.py:30: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
INSTALLED VERSIONS
commit : 3e89b4c
python : 3.8.6.final.0
python-bits : 64
OS : Linux
OS-release : 4.18.0-240.8.1.el8_3.x86_64
Version : #1 SMP Fri Dec 4 12:24:03 EST 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.0
numpy : 1.19.4
pytz : 2020.5
dateutil : 2.8.1
pip : 20.3.3
setuptools : 50.0.0.post20200830
Cython : 0.29.21
pytest : 6.2.1
hypothesis : None
sphinx : 3.4.1
blosc : None
feather : None
xlsxwriter : 1.3.7
lxml.etree : 4.6.2
html5lib : 1.1
pymysql : None
psycopg2 : 2.8.6 (dt dec pq3 ext lo64)
jinja2 : 2.11.2
IPython : 7.19.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : None
fsspec : 0.8.5
fastparquet : None
gcsfs : None
matplotlib : 3.3.3
numexpr : None
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.5.3
sqlalchemy : 1.3.22
tables : None
tabulate : None
xarray : 0.16.2
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.52.0
Thank you.
The text was updated successfully, but these errors were encountered: