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

Non expected result from to_msgpack with Python 2 and read_msgpack Python 3 #13591

Closed
VelizarVESSELINOV opened this issue Jul 9, 2016 · 1 comment
Labels
Bug Strings String extension data type and string data

Comments

@VelizarVESSELINOV
Copy link

Code Sample, a copy-pastable example if possible

Step 1. Run the code with Python 2 and Python 3

from sys import version

from pandas import DataFrame

print(version)
vers = version[0]

file_name = 'foobar'
data = {'a': [1], 'b': [2]}
dtf = DataFrame(data=data)
dtf.to_msgpack(file_name + '_py{}.msg'.format(vers))

Step 2. Run the code with Python 2 and Python 3

from sys import version

from pandas import read_msgpack

print(version)
vers = version[0]

file_name = 'foobar'
dtf = read_msgpack(file_name + '_py3.msg'.format(vers))
print(dtf.columns)
print(dtf.a)

dtf = read_msgpack(file_name + '_py2.msg'.format(vers))
# dtf.columns = [i.decode("utf-8") for i in dtf.columns]
print(dtf.columns)
print(dtf.a)

Expected Output

Same result with Python 2 and Python 3
Python 2 output:

2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
Index([u'a', u'b'], dtype='object')
0    1
Name: a, dtype: int64
Index([u'a', u'b'], dtype='object')
0    1
Name: a, dtype: int64

Python 3 output, the exception it is not expected:

3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Index(['a', 'b'], dtype='object')
0    1
Name: a, dtype: int64
Index([b'a', b'b'], dtype='object')
Traceback (most recent call last):
  File "/Users/VV/GitHub/doptimization/bug_msgpack_reader.py", line 16, in <module>
    print(dtf.a)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pandas/core/generic.py", line 2669, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'a'

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: None
pip: 8.1.2
setuptools: 20.6.7
Cython: None
numpy: 1.11.0
scipy: 0.16.1
statsmodels: None
xarray: None
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.1.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.0
nose: None
pip: 8.1.2
setuptools: 20.6.7
Cython: None
numpy: 1.11.0
scipy: 0.16.1
statsmodels: None
xarray: None
IPython: 4.0.1
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.0
openpyxl: 2.3.5
xlrd: 1.0.0
xlwt: 1.0.0
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
None
3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
Index(['a', 'b'], dtype='object')
0    1
Name: a, dtype: int64
Index([b'a', b'b'], dtype='object')
IPython: 4.0.1
sphinx: None
patsy: None
dateutil: 2.5.2
pytz: 2016.3
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.0
openpyxl: 2.3.5
xlrd: 1.0.0
xlwt: 1.0.0
xlsxwriter: None
lxml: None
bs4: 4.4.1
html5lib: None
httplib2: 0.9.2
apiclient: 1.5.0
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
None
@sinhrks sinhrks added Bug Strings String extension data type and string data Msgpack labels Jul 9, 2016
@jorisvandenbossche jorisvandenbossche added this to the Next Major Release milestone Jul 11, 2016
@mroeschke
Copy link
Member

Since we don't support Python 2 anymore and *_msgpack is deprecated, don't think there's any action on this issue. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Strings String extension data type and string data
Projects
None yet
Development

No branches or pull requests

4 participants