@@ -3556,12 +3556,14 @@ def _consolidate_inplace(self):
3556
3556
pass
3557
3557
3558
3558
3559
- def construction_error (tot_items , block_shape , axes ):
3559
+ def construction_error (tot_items , block_shape , axes , e = None ):
3560
3560
""" raise a helpful message about our construction """
3561
- raise ValueError ("Shape of passed values is %s, indices imply %s" % (
3562
- tuple (map (int , [tot_items ] + list (block_shape ))),
3563
- tuple (map (int , [len (ax ) for ax in axes ]))))
3564
-
3561
+ passed = tuple (map (int , [tot_items ] + list (block_shape )))
3562
+ implied = tuple (map (int , [len (ax ) for ax in axes ]))
3563
+ if passed == implied and e is not None :
3564
+ raise e
3565
+ raise ValueError ("Shape of passed values is {0}, indices imply {1}" .format (
3566
+ passed ,implied ))
3565
3567
3566
3568
def create_block_manager_from_blocks (blocks , axes ):
3567
3569
try :
@@ -3576,10 +3578,10 @@ def create_block_manager_from_blocks(blocks, axes):
3576
3578
mgr ._consolidate_inplace ()
3577
3579
return mgr
3578
3580
3579
- except (ValueError ):
3581
+ except (ValueError ) as e :
3580
3582
blocks = [getattr (b , 'values' , b ) for b in blocks ]
3581
3583
tot_items = sum (b .shape [0 ] for b in blocks )
3582
- construction_error (tot_items , blocks [0 ].shape [1 :], axes )
3584
+ construction_error (tot_items , blocks [0 ].shape [1 :], axes , e )
3583
3585
3584
3586
3585
3587
def create_block_manager_from_arrays (arrays , names , axes ):
@@ -3588,8 +3590,8 @@ def create_block_manager_from_arrays(arrays, names, axes):
3588
3590
mgr = BlockManager (blocks , axes )
3589
3591
mgr ._consolidate_inplace ()
3590
3592
return mgr
3591
- except (ValueError ):
3592
- construction_error (len (arrays ), arrays [0 ].shape [1 :], axes )
3593
+ except (ValueError ) as e :
3594
+ construction_error (len (arrays ), arrays [0 ].shape [1 :], axes , e )
3593
3595
3594
3596
3595
3597
def maybe_create_block_in_items_map (im , block ):
0 commit comments