Skip to content

BUG: pandas.Index takes multidimensional array as input #20285

Open
@csfarkas

Description

@csfarkas

Code Sample, a copy-pastable example if possible

idx = pd.Index(data=[[1, 2], [1, 2], [2, 3]])

# some cases where this causes error:
idx.get_duplicates()
idx.drop_duplicates()

Problem description

According to the documentation, pandas.Index takes a 1-dimensional array-like data as input, which is clearly violated in the example.

Expected Output

Option 1: pandas.Index should throw an error in this case.
Option 2: the documentation of pandas.Index should be updated. In this case, methods of the Index class should be checked, since nor get_duplicates, nor drop_duplicates are prepared for this kind of input.

Output of pd.show_versions()

INSTALLED VERSIONS

commit: c818a22
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.13.0-36-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.0.dev0+484.gc818a22
pytest: 3.4.2
pip: 9.0.1
setuptools: 38.5.1
Cython: 0.27.3
numpy: 1.14.1
scipy: 1.0.0
pyarrow: 0.8.0
xarray: 0.10.1
IPython: 6.2.1
sphinx: 1.7.1
patsy: 0.5.0
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: 1.2.1
tables: 3.4.2
numexpr: 2.6.4
feather: 0.4.0
matplotlib: 2.2.0
openpyxl: 2.5.0
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.0.2
lxml: 4.1.1
bs4: 4.6.0
html5lib: 1.0.1
sqlalchemy: 1.2.4
pymysql: 0.8.0
psycopg2: None
jinja2: 2.10
s3fs: 0.1.3
fastparquet: 0.1.4
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConstructorsSeries/DataFrame/Index/pd.array ConstructorsError ReportingIncorrect or improved errors from pandasIndexRelated 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