@@ -143,7 +143,7 @@ def _check_ndim(self, values, ndim):
143
143
ndim = values .ndim
144
144
145
145
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 [{} != {}]"
147
147
raise ValueError (msg .format (values .ndim , ndim ))
148
148
149
149
return ndim
@@ -259,7 +259,7 @@ def make_block_same_class(self, values, placement=None, ndim=None, dtype=None):
259
259
if dtype is not None :
260
260
# issue 19431 fastparquet is passing this
261
261
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." ,
263
263
FutureWarning ,
264
264
)
265
265
if placement is None :
@@ -399,7 +399,7 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
399
399
raise ValueError ("Limit must be greater than 0" )
400
400
if self .ndim > 2 :
401
401
raise NotImplementedError (
402
- "number of dimensions for 'fillna' " " is currently limited to 2"
402
+ "number of dimensions for 'fillna' is currently limited to 2"
403
403
)
404
404
mask [mask .cumsum (self .ndim - 1 ) > limit ] = False
405
405
@@ -533,7 +533,7 @@ def downcast(self, dtypes=None):
533
533
534
534
if not (dtypes == "infer" or isinstance (dtypes , dict )):
535
535
raise ValueError (
536
- "downcast must have a dictionary or 'infer' as " " its argument"
536
+ "downcast must have a dictionary or 'infer' as its argument"
537
537
)
538
538
539
539
# operate column-by-column
@@ -1025,7 +1025,7 @@ def putmask(self, mask, new, align=True, inplace=False, axis=0, transpose=False)
1025
1025
or mask [mask ].shape [- 1 ] == len (new )
1026
1026
or len (new ) == 1
1027
1027
):
1028
- raise ValueError ("cannot assign mismatch " " length to masked array" )
1028
+ raise ValueError ("cannot assign mismatch length to masked array" )
1029
1029
1030
1030
np .putmask (new_values , mask , new )
1031
1031
@@ -1381,16 +1381,7 @@ def shift(self, periods, axis=0, fill_value=None):
1381
1381
1382
1382
return [self .make_block (new_values )]
1383
1383
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 ):
1394
1385
"""
1395
1386
evaluate the block; return result block(s) from the result
1396
1387
@@ -1402,10 +1393,7 @@ def where(
1402
1393
errors : str, {'raise', 'ignore'}, default 'raise'
1403
1394
- ``raise`` : allow exceptions to be raised
1404
1395
- ``ignore`` : suppress exceptions. On error return original object
1405
-
1406
1396
axis : int
1407
- transpose : boolean
1408
- Set to True if self is stored with axes reversed
1409
1397
1410
1398
Returns
1411
1399
-------
@@ -1414,6 +1402,7 @@ def where(
1414
1402
import pandas .core .computation .expressions as expressions
1415
1403
1416
1404
assert errors in ["raise" , "ignore" ]
1405
+ transpose = self .ndim == 2
1417
1406
1418
1407
values = self .values
1419
1408
orig_other = other
@@ -1432,7 +1421,7 @@ def where(
1432
1421
cond = cond .T
1433
1422
1434
1423
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" )
1436
1425
1437
1426
# our where function
1438
1427
def func (cond , values , other ):
@@ -1473,7 +1462,6 @@ def func(cond, values, other):
1473
1462
errors = errors ,
1474
1463
try_cast = try_cast ,
1475
1464
axis = axis ,
1476
- transpose = transpose ,
1477
1465
)
1478
1466
return self ._maybe_downcast (blocks , "infer" )
1479
1467
@@ -1917,7 +1905,7 @@ def _slice(self, slicer):
1917
1905
1918
1906
if isinstance (slicer , tuple ) and len (slicer ) == 2 :
1919
1907
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" )
1921
1909
slicer = slicer [1 ]
1922
1910
1923
1911
return self .values [slicer ]
@@ -2004,16 +1992,7 @@ def shift(
2004
1992
)
2005
1993
]
2006
1994
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 ):
2017
1996
if isinstance (other , ABCDataFrame ):
2018
1997
# ExtensionArrays are 1-D, so if we get here then
2019
1998
# `other` should be a DataFrame with a single column.
@@ -2321,9 +2300,7 @@ def _try_coerce_args(self, other):
2321
2300
elif isinstance (other , (datetime , np .datetime64 , date )):
2322
2301
other = self ._box_func (other )
2323
2302
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" )
2327
2304
other = other .asm8 .view ("i8" )
2328
2305
elif hasattr (other , "dtype" ) and is_datetime64_dtype (other ):
2329
2306
other = other .astype ("i8" , copy = False ).view ("i8" )
@@ -2997,7 +2974,7 @@ def _replace_single(
2997
2974
# only one will survive
2998
2975
if to_rep_re and regex_re :
2999
2976
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"
3001
2978
)
3002
2979
3003
2980
# 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):
3181
3158
values , placement = placement or slice (0 , len (values ), 1 ), ndim = self .ndim
3182
3159
)
3183
3160
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 ):
3194
3162
# TODO(CategoricalBlock.where):
3195
3163
# This can all be deleted in favor of ExtensionBlock.where once
3196
3164
# we enforce the deprecation.
@@ -3205,19 +3173,11 @@ def where(
3205
3173
)
3206
3174
try :
3207
3175
# 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 )
3211
3177
except (TypeError , ValueError ):
3212
3178
warnings .warn (object_msg , FutureWarning , stacklevel = 6 )
3213
3179
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
3221
3181
)
3222
3182
return result
3223
3183
@@ -3286,7 +3246,7 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None, fastpath=No
3286
3246
if fastpath is not None :
3287
3247
# GH#19265 pyarrow is passing this
3288
3248
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." ,
3290
3250
FutureWarning ,
3291
3251
)
3292
3252
if klass is None :
0 commit comments