Skip to content

Pandas different between Python 2.7 and Python 3.5 #16380

Closed
@marabout2015

Description

@marabout2015

Code Sample, a copy-pastable example if possible

import pandas as pd
X = pd.DataFrame({'x': range(3)}, pd.Index(range(3), name='x'))
Y = X.x.apply(lambda x: pd.Series(range(x + 1), pd.Index(range(x + 1), name='y')))
Y.columns.names

Problem description

On Python 2.7, the above code results in:

FrozenList([u'y'])

while on Python 3.5, the same code results in:

FrozenList([None])

I see this difference between Python 2 and 3 for pandas 0.18.0, 0.19.2, and 0.20.1.

Expected Output

FrozenList([u'y'])

Or at least consistency.

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.5.2.final.0 python-bits: 64 OS: Windows OS-release: 8.1 machine: AMD64 processor: Intel64 Family 6 Model 45 Stepping 7, GenuineIntel byteorder: little LC_ALL: None LANG: None

pandas: 0.18.0
nose: 1.3.7
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.10.4
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.1.0
tables: 3.2.2
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.42.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Compatpandas objects compatability with Numpy or Python functionsNeeds TestsUnit test(s) needed to prevent regressionsgood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions