File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -444,14 +444,24 @@ def mask_missing(arr, values_to_mask):
444
444
mask = None
445
445
for x in nonna :
446
446
if mask is None :
447
- mask = arr == x
447
+
448
+ # numpy elementwise comparison warning
449
+ if is_numeric_dtype (arr ) and is_string_like (x ):
450
+ mask = False
451
+ else :
452
+ mask = arr == x
448
453
449
454
# if x is a string and arr is not, then we get False and we must
450
455
# expand the mask to size arr.shape
451
456
if np .isscalar (mask ):
452
457
mask = np .zeros (arr .shape , dtype = bool )
453
458
else :
454
- mask |= arr == x
459
+
460
+ # numpy elementwise comparison warning
461
+ if is_numeric_dtype (arr ) and is_string_like (x ):
462
+ mask |= False
463
+ else :
464
+ mask |= arr == x
455
465
456
466
if na_mask .any ():
457
467
if mask is None :
@@ -2382,6 +2392,9 @@ def _maybe_make_list(obj):
2382
2392
is_complex = lib .is_complex
2383
2393
2384
2394
2395
+ def is_string_like (obj ):
2396
+ return isinstance (obj , (compat .text_type , compat .string_types ))
2397
+
2385
2398
def is_iterator (obj ):
2386
2399
# python 3 generators have __next__ instead of next
2387
2400
return hasattr (obj , 'next' ) or hasattr (obj , '__next__' )
Original file line number Diff line number Diff line change 17
17
is_datetime64tz_dtype , is_datetimetz , is_sparse ,
18
18
array_equivalent , _maybe_convert_string_to_object ,
19
19
is_categorical , needs_i8_conversion , is_datetimelike_v_numeric ,
20
- is_internal_type )
20
+ is_string_like , is_internal_type )
21
21
from pandas .core .dtypes import DatetimeTZDtype
22
22
23
23
from pandas .core .index import Index , MultiIndex , _ensure_index
@@ -1085,6 +1085,11 @@ def get_result(other):
1085
1085
# avoid numpy warning of comparisons again None
1086
1086
if other is None :
1087
1087
result = not func .__name__ == 'eq'
1088
+
1089
+ # avoid numpy warning of elementwise comparisons to object
1090
+ elif self .is_numeric and is_string_like (other ):
1091
+ result = False
1092
+
1088
1093
else :
1089
1094
result = func (values , other )
1090
1095
You can’t perform that action at this time.
0 commit comments