Open csfarkas opened 6 years ago
Definitely option 1, as we also want to avoid
In [2]: idx = pd.Index(data=[[1, 2], [1, 2], [2, 3]])
In [3]: id(idx)
Out[3]: 139839285680560
In [4]: idx[0][0] = 1000
In [5]: idx
Out[5]: Index([[1000, 2], [1, 2], [2, 3]], dtype='object')
In [6]: id(idx)
Out[6]: 139839285680560
... unless we consider option 3: create a MultiIndex
, as in
In [2]: pd.Index(data=[(1, 2), (1, 2), (2, 3)])
Out[2]:
MultiIndex([(1, 2),
(1, 2),
(2, 3)],
)
In any case, xref: #17246
Code Sample, a copy-pastable example if possible
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()