-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
json encoding for python 2 #15715
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
this is currently an open issue xref #13774 we have a tests but its not implemented on the writer side; the reader side should work. can you provide an reproducible example showing this is not work. can add that as a test. |
# path = "path_to/example.txt"
try:
# not working
df1 = pd.read_json(path, encoding='cp1251')
except:
print "pd read failed"
else:
print "pd read complete"
try:
import json
with open(path, 'r') as f:
js = json.load(f, encoding='cp1251')
df2 = pd.DataFrame(js)
assert df2.shape == (1, 19)
except:
print "json read failed"
else:
print "json read complete" I do achive "pd read failed", "json read complete" with attached 'example.txt'. |
yep I agree. something not getting decoded properly (works on py3, but not on 2). Want to have a look?
3.5
|
duplicate of #13774 |
Code Sample, a copy-pastable example if possible
Problem description
It is not mentioned explicitly in docstring that
encoding
option used in py3 only.Currently
pd.read_json
mostly ignoresencoding=
option in python2.Function
pd.common._get_handle
warns about using encoding with compression, but silently continues without actually usingencoding
otherwise.It looks like subtasks are split in unfavourable way to pass encoding up to
json.loads
call.Expected Output
One might expect pandas use encoding, to get life easier (as pandas usually do ;) ).
Or at least properly warn that option is ignored.
Output of
pd.show_versions()
pandas: 0.19.2
nose: 1.3.7
pip: 9.0.1
setuptools: 28.8.0.post20161110
Cython: 0.24.1
numpy: 1.12.0
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.6.2
matplotlib: 2.0.0
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.2
lxml: 3.6.4
bs4: 4.3.2
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: 0.7.6.None
psycopg2: None
jinja2: 2.8
boto: 2.40.0
pandas_datareader: None
The text was updated successfully, but these errors were encountered: