Skip to content
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

read_json with typ="series" of json list of bools results in timestamps/Exception #31464

Closed
stewit opened this issue Jan 30, 2020 · 1 comment · Fixed by #33373
Closed

read_json with typ="series" of json list of bools results in timestamps/Exception #31464

stewit opened this issue Jan 30, 2020 · 1 comment · Fixed by #33373
Assignees
Labels
Bug IO JSON read_json, to_json, json_normalize
Milestone

Comments

@stewit
Copy link

stewit commented Jan 30, 2020

Code Sample, a copy-pastable example if possible

import pandas as pd
pd.read_json('[true, true, false]', typ="series")

results in the following Pandas Series object in older Pandas versions:

0   1970-01-01 00:00:01
1   1970-01-01 00:00:01
2   1970-01-01 00:00:00
dtype: datetime64[ns]

Since 1.0.0 it raises TypeError: <class 'bool'> is not convertible to datetime

Problem description

The expected output would be a Pandas Series of bools. Note that

  • with typ="frame" it works and the result is a dataframe with one column with bool values
  • with convert_dates set to False correctly outputs a Series of boolean values

This is a problem because

  • users would expect a Series of bools (and neither an exception nor a series of timestamps)
  • it is inconsistent with the "frame" case

Expected Output

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

INSTALLED VERSIONS

commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.13-arch1-1
machine : x86_64
processor :
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8

pandas : 1.0.0
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.0.2
setuptools : 44.0.0
Cython : 0.29.14
pytest : 5.2.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.4.2
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.2.4
pyxlsb : None
s3fs : None
scipy : 1.3.2
sqlalchemy : 1.3.11
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None

@jorisvandenbossche jorisvandenbossche added Bug IO JSON read_json, to_json, json_normalize labels Jan 31, 2020
@jessefarnham
Copy link
Contributor

take

jessefarnham added a commit to jessefarnham/pandas that referenced this issue Apr 7, 2020
…eries

Add a missing exception type to the except clause, to cover
the TypeError that is thrown by Cythonized array_to_datetime
function when trying to convert bool to nonseconds.
jessefarnham added a commit to jessefarnham/pandas that referenced this issue Apr 7, 2020
…eries

Add a missing exception type to the except clause, to cover
the TypeError that is thrown by Cythonized array_to_datetime
function when trying to convert bool to nonseconds.
jessefarnham added a commit to jessefarnham/pandas that referenced this issue Apr 7, 2020
…eries

Add a missing exception type to the except clause, to cover
the TypeError that is thrown by Cythonized array_to_datetime
function when trying to convert bool to nonseconds.
@jreback jreback added this to the 1.1 milestone Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO JSON read_json, to_json, json_normalize
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants