Skip to content

Make pd.Series(index=values) equivalent to pd.Series(index=pd.Index(values))? #18484

Open
@toobaz

Description

@toobaz

Code Sample, a copy-pastable example if possible

In [2]: d = {(0, 1) : 2, (3, 4) : 5}

In [3]: pd.Index(d)
Out[3]: Index([(0, 1), (3, 4)], dtype='object')

In [4]: pd.Index(list(d))
Out[4]: 
MultiIndex(levels=[[0, 3], [1, 4]],
           labels=[[0, 1], [0, 1]])

In [5]: pd.Series(d).index
Out[5]: 
MultiIndex(levels=[[0, 3], [1, 4]],
           labels=[[0, 1], [0, 1]])

In [6]: pd.Series(index=list(d)).index
Out[6]: Index([(0, 1), (3, 4)], dtype='object')

Problem description

I guess Out[3]: and Out[6]: are wrong.

Expected Output

Out[4]:

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.5.3.final.0
python-bits: 64
OS: Linux
OS-release: 4.9.0-4-amd64
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.22.0.dev0+202.g97bd66ea8
pytest: 3.0.6
pip: 9.0.1
setuptools: 33.1.1
Cython: 0.25.2
numpy: 1.12.1
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.2.2
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: 1.2.0
tables: 3.3.0
numexpr: 2.6.1
feather: 0.3.1
matplotlib: 2.0.0
openpyxl: 2.3.0
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: 3.7.1
bs4: 4.5.3
html5lib: 0.999999999
sqlalchemy: 1.0.15
pymysql: None
psycopg2: None
jinja2: 2.8
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConstructorsSeries/DataFrame/Index/pd.array ConstructorsIndexRelated to the Index class or subclasses

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions