@@ -532,10 +532,16 @@ def astype(self, dtype, copy=False, errors='raise', values=None, **kwargs):
532532 ** kwargs )
533533
534534 def _astype (self , dtype , copy = False , errors = 'raise' , values = None ,
535- klass = None , mgr = None , raise_on_error = False , ** kwargs ):
535+ klass = None , mgr = None , ** kwargs ):
536536 """
537- Coerce to the new type (if copy=True, return a new copy)
538- raise on an except if raise == True
537+ Coerce to the new type
538+
539+ dtype : str, dtype convertible
540+ copy : boolean, default False
541+ copy if indicated
542+ errors : str, {'raise', 'ignore'}, default 'ignore'
543+ - ``raise`` : allow exceptions to be raised
544+ - ``ignore`` : suppress exceptions. On error return original object
539545 """
540546 errors_legal_values = ('raise' , 'ignore' )
541547
@@ -1248,16 +1254,18 @@ def shift(self, periods, axis=0, mgr=None):
12481254
12491255 return [self .make_block (new_values , fastpath = True )]
12501256
1251- def eval (self , func , other , raise_on_error = True , try_cast = False , mgr = None ):
1257+ def eval (self , func , other , errors = 'raise' , try_cast = False , mgr = None ):
12521258 """
12531259 evaluate the block; return result block from the result
12541260
12551261 Parameters
12561262 ----------
12571263 func : how to combine self, other
12581264 other : a ndarray/object
1259- raise_on_error : if True, raise when I can't perform the function,
1260- False by default (and just return the data that we had coming in)
1265+ errors : str, {'raise', 'ignore'}, default 'raise'
1266+ - ``raise`` : allow exceptions to be raised
1267+ - ``ignore`` : suppress exceptions. On error return original object
1268+
12611269 try_cast : try casting the results to the input type
12621270
12631271 Returns
@@ -1295,7 +1303,7 @@ def eval(self, func, other, raise_on_error=True, try_cast=False, mgr=None):
12951303 except TypeError :
12961304 block = self .coerce_to_target_dtype (orig_other )
12971305 return block .eval (func , orig_other ,
1298- raise_on_error = raise_on_error ,
1306+ errors = errors ,
12991307 try_cast = try_cast , mgr = mgr )
13001308
13011309 # get the result, may need to transpose the other
@@ -1337,7 +1345,7 @@ def get_result(other):
13371345 # error handler if we have an issue operating with the function
13381346 def handle_error ():
13391347
1340- if raise_on_error :
1348+ if errors == 'raise' :
13411349 # The 'detail' variable is defined in outer scope.
13421350 raise TypeError ('Could not operate %s with block values %s' %
13431351 (repr (other ), str (detail ))) # noqa
@@ -1383,7 +1391,7 @@ def handle_error():
13831391 result = _block_shape (result , ndim = self .ndim )
13841392 return [self .make_block (result , fastpath = True , )]
13851393
1386- def where (self , other , cond , align = True , raise_on_error = True ,
1394+ def where (self , other , cond , align = True , errors = 'raise' ,
13871395 try_cast = False , axis = 0 , transpose = False , mgr = None ):
13881396 """
13891397 evaluate the block; return result block(s) from the result
@@ -1393,8 +1401,10 @@ def where(self, other, cond, align=True, raise_on_error=True,
13931401 other : a ndarray/object
13941402 cond : the condition to respect
13951403 align : boolean, perform alignment on other/cond
1396- raise_on_error : if True, raise when I can't perform the function,
1397- False by default (and just return the data that we had coming in)
1404+ errors : str, {'raise', 'ignore'}, default 'raise'
1405+ - ``raise`` : allow exceptions to be raised
1406+ - ``ignore`` : suppress exceptions. On error return original object
1407+
13981408 axis : int
13991409 transpose : boolean
14001410 Set to True if self is stored with axes reversed
@@ -1404,6 +1414,7 @@ def where(self, other, cond, align=True, raise_on_error=True,
14041414 a new block(s), the result of the func
14051415 """
14061416 import pandas .core .computation .expressions as expressions
1417+ assert errors in ['raise' , 'ignore' ]
14071418
14081419 values = self .values
14091420 orig_other = other
@@ -1436,9 +1447,9 @@ def func(cond, values, other):
14361447
14371448 try :
14381449 return self ._try_coerce_result (expressions .where (
1439- cond , values , other , raise_on_error = True ))
1450+ cond , values , other ))
14401451 except Exception as detail :
1441- if raise_on_error :
1452+ if errors == 'raise' :
14421453 raise TypeError ('Could not operate [%s] with block values '
14431454 '[%s]' % (repr (other ), str (detail )))
14441455 else :
@@ -1454,10 +1465,10 @@ def func(cond, values, other):
14541465 except TypeError :
14551466
14561467 # we cannot coerce, return a compat dtype
1457- # we are explicity ignoring raise_on_error here
1468+ # we are explicity ignoring errors
14581469 block = self .coerce_to_target_dtype (other )
14591470 blocks = block .where (orig_other , cond , align = align ,
1460- raise_on_error = raise_on_error ,
1471+ errors = errors ,
14611472 try_cast = try_cast , axis = axis ,
14621473 transpose = transpose )
14631474 return self ._maybe_downcast (blocks , 'infer' )
@@ -2745,7 +2756,7 @@ def sp_index(self):
27452756 def kind (self ):
27462757 return self .values .kind
27472758
2748- def _astype (self , dtype , copy = False , raise_on_error = True , values = None ,
2759+ def _astype (self , dtype , copy = False , errors = 'raise' , values = None ,
27492760 klass = None , mgr = None , ** kwargs ):
27502761 if values is None :
27512762 values = self .values
0 commit comments