wesm/pandas — Issue #497: Better error messages (or bug?)
Author: JanSchulz
Created: 2011-12-16 18:35:02+00:00
State: open

I'm trying to build a dataframe from a list of list and I get an "AssertionError" and I have no idea what I did wrong or what I should do differently. A shorted version of the data and code:

>>> pprint(_fields)
[ 'name',
'timescited',
'weight',
'closeness',
'betweenness',
'degree',
'numberofworks',
'pagerank',
'pages',
'constraint',
'citationaverage',
'eigenvector']
>>> pprint(_data2)
[ ['Huselid, Ma', 'Gulati, R', 'Damanpour, F', 'Mcallister, Dj', 'Tsai, Wp'],
[2721, 5251, 1269, 1287, 2834],
[6, 17, 6, 3, 6],
[ 0.0002510562854116362,
0.00025108339541739277,
0.00025105435150127433,
0.00025106898828104144,
0.0002510723039607744],
[ 23311.0,
173596.65383408728,
79279.82282582425,
18701.108026093425,
57261.74716265692],
[4, 11, 9, 3, 7],
[6, 17, 6, 3, 6],
[ 0.0001438440250079284,
0.0003063098736173118,
0.00027071793856870986,
7.839463995668608e-05,
0.00020047003509480145],
[130, 387, 148, 68, 88],
[ 0.28573421556122447,
0.12411566040831735,
0.19959178902739988,
0.3703749360800643,
0.200788126303937],
[453, 308, 211, 429, 472],
[ 5.889013732612275e-08,
0.0005066654664776551,
4.567816673280219e-07,
2.4226314239685797e-06,
4.069482619394397e-07]]
>>> df = DataFrame(_data2, columns=_fields )
Traceback (most recent call last):
File "", line 1, in
File "C:\portabel\Python27\lib\site-packages\pandas\core\frame.py", line 208, in __init__
copy=copy)
File "C:\portabel\Python27\lib\site-packages\pandas\core\frame.py", line 273, in _init_ndarray
block = make_block(values.T, columns, columns)
File "C:\portabel\Python27\lib\site-packages\pandas\core\internals.py", line 211, in make_block
do_integrity_check=do_integrity_check)
File "C:\portabel\Python27\lib\site-packages\pandas\core\internals.py", line 26, in __init__
assert(len(items) == len(values))
AssertionError
>>>

It would be nice if pandas could output a more descriptive error message in case some inputs are not what pandas expects.

Thanks a lot for the lib!

Jan