-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Spurious FutureWarning
when using pd.read_json()
#59511
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
I test with latest dev version, seems the problem is solved. Will take a closer look |
Thanks for the report, confirmed on 2.2.x. At a quick glance, it looks like this line: pandas/pandas/io/json/_json.py Line 1148 in 0851ac3
should be passing Additionally, we could catch the warning here: pandas/pandas/io/json/_json.py Line 1360 in 795cce2
Further investigations and PRs to fix are welcome! |
Take |
seems like The I was trying to see the difference between the pd.read_json() 2.2.x branch with main, can't really find much except that the specific FutureWarning is now removed from the main branch. @rhshadrach Any ideas for a fix? Thanks |
I may be misunderstanding, but I think you're talking about the default value of Somewhat separately, it seems to me we should be adhering to a user's request when they pass |
Thanks for the clarification @rhshadrach. I misunderstood the code on my previous message |
I don't think this OP issue reproduces on main (was presumably fixed by #59124 - haven't run a bisect). I think it's better to create a new issue for the comment (speaking from the perspective of a release-notes reading user)
which I believe is what @KevsterAmp's PR aims to do. |
I believe the warning has been removed in preparation of pandas 3.0. The warning still exists on 2.2, and I think this is eligible for a backport. In fact, we would skip a PR into main because this is no longer an issue on main, so a PR straight into either 2.2.x or 2.3.x. |
Pandas version checks
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 main branch of pandas.
Reproducible Example
Issue Description
read_json()
works correctly but generates three spurious and annoying warnings:These warnings are spurious because the usage of
to_datetime
is not controlled by user. The warnings are annoying because there are so many of them.This was previously raised on Stack Overflow here 3 months ago and it accumulated almost 400 visits: https://stackoverflow.com/questions/78454457/pandas-read-json-future-warning-the-behavior-of-to-datetime-with-unit-when
Expected Behavior
The warnings are suppressed.
Installed Versions
INSTALLED VERSIONS
commit : d9cdd2e
python : 3.10.10.final.0
python-bits : 64
OS : Linux
OS-release : 6.5.0-44-generic
Version : #44-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 7 15:10:09 UTC 2024
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 2.2.2
numpy : 2.0.1
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 65.5.0
pip : 22.3.1
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.4
IPython : 8.26.0
pandas_datareader : None
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.12.3
bottleneck : None
dataframe-api-compat : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
python-calamine : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2024.1
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: