@@ -143,7 +143,7 @@ def _check_ndim(self, values, ndim):
143143 ndim = values .ndim
144144
145145 if self ._validate_ndim and values .ndim != ndim :
146- msg = "Wrong number of dimensions. values.ndim != ndim " " [{} != {}]"
146+ msg = "Wrong number of dimensions. values.ndim != ndim [{} != {}]"
147147 raise ValueError (msg .format (values .ndim , ndim ))
148148
149149 return ndim
@@ -259,7 +259,7 @@ def make_block_same_class(self, values, placement=None, ndim=None, dtype=None):
259259 if dtype is not None :
260260 # issue 19431 fastparquet is passing this
261261 warnings .warn (
262- "dtype argument is deprecated, will be removed " " in a future release." ,
262+ "dtype argument is deprecated, will be removed in a future release." ,
263263 FutureWarning ,
264264 )
265265 if placement is None :
@@ -399,7 +399,7 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
399399 raise ValueError ("Limit must be greater than 0" )
400400 if self .ndim > 2 :
401401 raise NotImplementedError (
402- "number of dimensions for 'fillna' " " is currently limited to 2"
402+ "number of dimensions for 'fillna' is currently limited to 2"
403403 )
404404 mask [mask .cumsum (self .ndim - 1 ) > limit ] = False
405405
@@ -533,7 +533,7 @@ def downcast(self, dtypes=None):
533533
534534 if not (dtypes == "infer" or isinstance (dtypes , dict )):
535535 raise ValueError (
536- "downcast must have a dictionary or 'infer' as " " its argument"
536+ "downcast must have a dictionary or 'infer' as its argument"
537537 )
538538
539539 # operate column-by-column
@@ -1025,7 +1025,7 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False)
10251025 or mask [mask ].shape [- 1 ] == len (new )
10261026 or len (new ) == 1
10271027 ):
1028- raise ValueError ("cannot assign mismatch " " length to masked array" )
1028+ raise ValueError ("cannot assign mismatch length to masked array" )
10291029
10301030 np .putmask (new_values , mask , new )
10311031
@@ -1381,16 +1381,7 @@ def shift(self, periods, axis=0, fill_value=None):
13811381
13821382 return [self .make_block (new_values )]
13831383
1384- def where (
1385- self ,
1386- other ,
1387- cond ,
1388- align = True ,
1389- errors = "raise" ,
1390- try_cast = False ,
1391- axis = 0 ,
1392- transpose = False ,
1393- ):
1384+ def where (self , other , cond , align = True , errors = "raise" , try_cast = False , axis = 0 ):
13941385 """
13951386 evaluate the block; return result block(s) from the result
13961387
@@ -1402,10 +1393,7 @@ def where(
14021393 errors : str, {'raise', 'ignore'}, default 'raise'
14031394 - ``raise`` : allow exceptions to be raised
14041395 - ``ignore`` : suppress exceptions. On error return original object
1405-
14061396 axis : int
1407- transpose : boolean
1408- Set to True if self is stored with axes reversed
14091397
14101398 Returns
14111399 -------
@@ -1414,6 +1402,7 @@ def where(
14141402 import pandas .core .computation .expressions as expressions
14151403
14161404 assert errors in ["raise" , "ignore" ]
1405+ transpose = self .ndim == 2
14171406
14181407 values = self .values
14191408 orig_other = other
@@ -1432,7 +1421,7 @@ def where(
14321421 cond = cond .T
14331422
14341423 if not hasattr (cond , "shape" ):
1435- raise ValueError ("where must have a condition that is ndarray " " like" )
1424+ raise ValueError ("where must have a condition that is ndarray like" )
14361425
14371426 # our where function
14381427 def func (cond , values , other ):
@@ -1473,7 +1462,6 @@ def func(cond, values, other):
14731462 errors = errors ,
14741463 try_cast = try_cast ,
14751464 axis = axis ,
1476- transpose = transpose ,
14771465 )
14781466 return self ._maybe_downcast (blocks , "infer" )
14791467
@@ -1917,7 +1905,7 @@ def _slice(self, slicer):
19171905
19181906 if isinstance (slicer , tuple ) and len (slicer ) == 2 :
19191907 if not com .is_null_slice (slicer [0 ]):
1920- raise AssertionError ("invalid slicing for a 1-ndim " " categorical" )
1908+ raise AssertionError ("invalid slicing for a 1-ndim categorical" )
19211909 slicer = slicer [1 ]
19221910
19231911 return self .values [slicer ]
@@ -2004,16 +1992,7 @@ def shift(
20041992 )
20051993 ]
20061994
2007- def where (
2008- self ,
2009- other ,
2010- cond ,
2011- align = True ,
2012- errors = "raise" ,
2013- try_cast = False ,
2014- axis = 0 ,
2015- transpose = False ,
2016- ):
1995+ def where (self , other , cond , align = True , errors = "raise" , try_cast = False , axis = 0 ):
20171996 if isinstance (other , ABCDataFrame ):
20181997 # ExtensionArrays are 1-D, so if we get here then
20191998 # `other` should be a DataFrame with a single column.
@@ -2321,9 +2300,7 @@ def _try_coerce_args(self, other):
23212300 elif isinstance (other , (datetime , np .datetime64 , date )):
23222301 other = self ._box_func (other )
23232302 if getattr (other , "tz" ) is not None :
2324- raise TypeError (
2325- "cannot coerce a Timestamp with a tz on a " "naive Block"
2326- )
2303+ raise TypeError ("cannot coerce a Timestamp with a tz on a naive Block" )
23272304 other = other .asm8 .view ("i8" )
23282305 elif hasattr (other , "dtype" ) and is_datetime64_dtype (other ):
23292306 other = other .astype ("i8" , copy = False ).view ("i8" )
@@ -2997,7 +2974,7 @@ def _replace_single(
29972974 # only one will survive
29982975 if to_rep_re and regex_re :
29992976 raise AssertionError (
3000- "only one of to_replace and regex can be " " regex compilable"
2977+ "only one of to_replace and regex can be regex compilable"
30012978 )
30022979
30032980 # if regex was passed as something that can be a regex (rather than a
@@ -3181,16 +3158,7 @@ def concat_same_type(self, to_concat, placement=None):
31813158 values , placement = placement or slice (0 , len (values ), 1 ), ndim = self .ndim
31823159 )
31833160
3184- def where (
3185- self ,
3186- other ,
3187- cond ,
3188- align = True ,
3189- errors = "raise" ,
3190- try_cast = False ,
3191- axis = 0 ,
3192- transpose = False ,
3193- ):
3161+ def where (self , other , cond , align = True , errors = "raise" , try_cast = False , axis = 0 ):
31943162 # TODO(CategoricalBlock.where):
31953163 # This can all be deleted in favor of ExtensionBlock.where once
31963164 # we enforce the deprecation.
@@ -3205,19 +3173,11 @@ def where(
32053173 )
32063174 try :
32073175 # Attempt to do preserve categorical dtype.
3208- result = super ().where (
3209- other , cond , align , errors , try_cast , axis , transpose
3210- )
3176+ result = super ().where (other , cond , align , errors , try_cast , axis )
32113177 except (TypeError , ValueError ):
32123178 warnings .warn (object_msg , FutureWarning , stacklevel = 6 )
32133179 result = self .astype (object ).where (
3214- other ,
3215- cond ,
3216- align = align ,
3217- errors = errors ,
3218- try_cast = try_cast ,
3219- axis = axis ,
3220- transpose = transpose ,
3180+ other , cond , align = align , errors = errors , try_cast = try_cast , axis = axis
32213181 )
32223182 return result
32233183
@@ -3286,7 +3246,7 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None, fastpath=No
32863246 if fastpath is not None :
32873247 # GH#19265 pyarrow is passing this
32883248 warnings .warn (
3289- "fastpath argument is deprecated, will be removed " " in a future release." ,
3249+ "fastpath argument is deprecated, will be removed in a future release." ,
32903250 FutureWarning ,
32913251 )
32923252 if klass is None :
0 commit comments