@@ -3556,12 +3556,14 @@ def _consolidate_inplace(self):
35563556 pass
35573557
35583558
3559- def construction_error (tot_items , block_shape , axes ):
3559+ def construction_error (tot_items , block_shape , axes , e = None ):
35603560 """ 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 ))
35653567
35663568def create_block_manager_from_blocks (blocks , axes ):
35673569 try :
@@ -3576,10 +3578,10 @@ def create_block_manager_from_blocks(blocks, axes):
35763578 mgr ._consolidate_inplace ()
35773579 return mgr
35783580
3579- except (ValueError ):
3581+ except (ValueError ) as e :
35803582 blocks = [getattr (b , 'values' , b ) for b in blocks ]
35813583 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 )
35833585
35843586
35853587def create_block_manager_from_arrays (arrays , names , axes ):
@@ -3588,8 +3590,8 @@ def create_block_manager_from_arrays(arrays, names, axes):
35883590 mgr = BlockManager (blocks , axes )
35893591 mgr ._consolidate_inplace ()
35903592 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 )
35933595
35943596
35953597def maybe_create_block_in_items_map (im , block ):
0 commit comments