We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
from __future__ import unicode_literals import pandas as pd pd.DataFrame([{'id': '10', 'title': 'hello'}]).set_index('id').to_records()
the code above will report following error:
TypeError Traceback (most recent call last) <ipython-input-40-056b33fad34d> in <module>() ----> 1 pd.DataFrame([{'id': '10', 'title': 'hello'}]).set_index('id').to_records() /usr/local/lib/python2.7/site-packages/pandas/core/frame.pyc in to_records(self, index, convert_datetime64) 1068 names = lmap(str, self.columns) 1069 -> 1070 dtype = np.dtype([(x, v.dtype) for x, v in zip(names, arrays)]) 1071 return np.rec.fromarrays(arrays, dtype=dtype, names=names) 1072 TypeError: data type not understood
If I comment out from __future__ import unicode_literals, the code above will work fine.
from __future__ import unicode_literals
rec.array([('10', 'hello')], dtype=[('id', 'O'), ('title', 'O')])
pd.show_versions()
commit: None python: 2.7.11.final.0 python-bits: 64 OS: Darwin OS-release: 15.4.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: zh_CN.UTF-8
pandas: 0.18.1 nose: None pip: 8.1.1 setuptools: 19.4 Cython: None numpy: 1.11.0 scipy: None statsmodels: None xarray: None IPython: 4.2.0 sphinx: 1.3.5 patsy: None dateutil: 2.5.3 pytz: 2016.4 blosc: None bottleneck: None tables: None numexpr: None matplotlib: None openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml: None bs4: 4.4.1 html5lib: None httplib2: None apiclient: None sqlalchemy: 1.0.12 pymysql: None psycopg2: None jinja2: 2.8 boto: None pandas_datareader: None
The text was updated successfully, but these errors were encountered:
https://github.com/pydata/pandas/blob/master/pandas/core/frame.py#L1068 should prob be
lmap(compat.u, self.columns)
want to do a PR?
Sorry, something went wrong.
OK, I will have a try.
原始邮件 发件人:Jeff [email protected] 收件人:pydata/[email protected] 抄送:[email protected]; [email protected] 发送时间:2016年5月14日(周六) 00:56 主题:Re: [pydata/pandas] unicode_literals conflict with to_records(#13172)
https://github.com/pydata/pandas/blob/master/pandas/core/frame.py#L1068 should prob be lmap(compat.u, self.columns) want to do a PR? — You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub
BUG: fix to_records confict with unicode_literals pandas-dev#13172
62b00d3
20ea406
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
the code above will report following error:
If I comment out
from __future__ import unicode_literals
, the code above will work fine.output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: Darwin
OS-release: 15.4.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: zh_CN.UTF-8
pandas: 0.18.1
nose: None
pip: 8.1.1
setuptools: 19.4
Cython: None
numpy: 1.11.0
scipy: None
statsmodels: None
xarray: None
IPython: 4.2.0
sphinx: 1.3.5
patsy: None
dateutil: 2.5.3
pytz: 2016.4
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.12
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: