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_numeric_v_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
@@ -1082,8 +1082,16 @@ def eval(self, func, other, raise_on_error=True, try_cast=False, mgr=None):
1082
1082
# get the result, may need to transpose the other
1083
1083
def get_result (other ):
1084
1084
1085
- # compute
1086
- result = func (values , other )
1085
+ # avoid numpy warning of comparisons again None
1086
+ if other is None :
1087
+ result = not func .__name__ == 'eq'
1088
+
1089
+ # avoid numpy warning of elementwise comparisons to object
1090
+ elif is_numeric_v_string_like (values , other ):
1091
+ result = False
1092
+
1093
+ else :
1094
+ result = func (values , other )
1087
1095
1088
1096
# mask if needed
1089
1097
if isinstance (values_mask , np .ndarray ) and values_mask .any ():
@@ -3214,7 +3222,7 @@ def get(self, item, fastpath=True):
3214
3222
else :
3215
3223
3216
3224
if isnull (item ):
3217
- raise ValueError ("cannot label index with a null key" )
3225
+ raise TypeError ("cannot label index with a null key" )
3218
3226
3219
3227
indexer = self .items .get_indexer_for ([item ])
3220
3228
return self .reindex_indexer (new_axis = self .items [indexer ],
@@ -4251,11 +4259,16 @@ def _possibly_compare(a, b, op):
4251
4259
4252
4260
# numpy deprecation warning to have i8 vs integer comparisions
4253
4261
if is_datetimelike_v_numeric (a , b ):
4254
- res = False
4262
+ result = False
4263
+
4264
+ # numpy deprecation warning if comparing numeric vs string-like
4265
+ elif is_numeric_v_string_like (a , b ):
4266
+ result = False
4267
+
4255
4268
else :
4256
- res = op (a , b )
4269
+ result = op (a , b )
4257
4270
4258
- if np .isscalar (res ) and (is_a_array or is_b_array ):
4271
+ if lib .isscalar (result ) and (is_a_array or is_b_array ):
4259
4272
type_names = [type (a ).__name__ , type (b ).__name__ ]
4260
4273
4261
4274
if is_a_array :
@@ -4265,7 +4278,7 @@ def _possibly_compare(a, b, op):
4265
4278
type_names [1 ] = 'ndarray(dtype=%s)' % b .dtype
4266
4279
4267
4280
raise TypeError ("Cannot compare types %r and %r" % tuple (type_names ))
4268
- return res
4281
+ return result
4269
4282
4270
4283
4271
4284
def _concat_indexes (indexes ):
0 commit comments