A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/13172 below:

unicode_literals conflict with to_records · Issue #13172 · pandas-dev/pandas · GitHub

Code Sample, a copy-pastable example if possible
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.

rec.array([('10', 'hello')],
          dtype=[('id', 'O'), ('title', 'O')])
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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4