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

MultiIndex.from_arrays() does not check lenghts #13599

Closed
toobaz opened this issue Jul 9, 2016 · 5 comments
Closed

MultiIndex.from_arrays() does not check lenghts #13599

toobaz opened this issue Jul 9, 2016 · 5 comments
Labels
Error Reporting Incorrect or improved errors from pandas MultiIndex
Milestone

Comments

@toobaz
Copy link
Member

toobaz commented Jul 9, 2016

Code Sample, a copy-pastable example if possible

In [2]: pd.MultiIndex.from_arrays([[1,2,3], ['a', 'b']])
Out[2]: 
MultiIndex(levels=[[1, 2, 3], ['a', 'b']],
           labels=[[0, 1, 2], [0, 1]])

In [3]: pd.MultiIndex.from_arrays([[1,2,3], ['a', 'b']]).values
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-65e6fa14e07f> in <module>()
----> 1 pd.MultiIndex.from_arrays([[1,2,3], ['a', 'b']]).values

/home/nobackup/repo/pandas/pandas/indexes/multi.py in values(self)
    552             values.append(taken)
    553 
--> 554         self._tuples = lib.fast_zip(values)
    555         return self._tuples
    556 

/home/nobackup/repo/pandas/pandas/lib.pyx in pandas.lib.fast_zip (pandas/lib.c:11131)()
    587         it = <flatiter> PyArray_IterNew(arr)
    588         if len(arr) != n:
--> 589             raise ValueError('all arrays must be same length')
    590 
    591         for i in range(n):

ValueError: all arrays must be same length

Expected Output

The first previous command should already raise an error.

output of pd.show_versions()


In [4]: pd.show_versions()

INSTALLED VERSIONS
------------------
commit: a63bd12529ff309d957d714825b1753d0e02b7fa
python: 3.5.1.final.0
python-bits: 64
OS: Linux
OS-release: 4.5.0-2-amd64
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: it_IT.utf8
LOCALE: it_IT.UTF-8

pandas: 0.18.1+174.ga63bd12
nose: 1.3.7
pip: 1.5.6
setuptools: 18.4
Cython: 0.23.4
numpy: 1.10.4
scipy: 0.16.0
statsmodels: 0.8.0.dev0+111ddc0
xarray: None
IPython: 5.0.0.dev
sphinx: 1.3.1
patsy: 0.3.0-dev
dateutil: 2.2
pytz: 2012c
blosc: None
bottleneck: 1.1.0dev
tables: 3.2.2
numexpr: 2.5
matplotlib: 1.5.1
openpyxl: None
xlrd: 0.9.4
xlwt: 1.1.2
xlsxwriter: 0.7.3
lxml: None
bs4: 4.4.0
html5lib: 0.999
httplib2: 0.9.1
apiclient: 1.5.0
sqlalchemy: 1.0.11
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.38.0
pandas_datareader: 0.2.1

@jreback jreback added Error Reporting Incorrect or improved errors from pandas MultiIndex labels Jul 9, 2016
@jreback jreback added this to the Next Major Release milestone Jul 9, 2016
@sahildua2305
Copy link
Contributor

@jreback Hi, I'd like to contribute to this library. Can you please help me in starting with it as well as tagging me in some task perfect for a beginner?

Thanks! 😄

@jreback
Copy link
Contributor

jreback commented Jul 10, 2016

@sahildua2305 see contributing docs here

things tagged a 'Difficulty Novice' are generally pretty straightforward (like this issue)

@sahildua2305
Copy link
Contributor

@jreback Thanks for pointers!

However this link doesn't work for me. Can you please check once?

@jreback
Copy link
Contributor

jreback commented Jul 10, 2016

seems ok to me.

@sahildua2305
Copy link
Contributor

Accessible now. Thanks once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas MultiIndex
Projects
None yet
3 participants