1717 is_datetime64tz_dtype , is_datetimetz , is_sparse ,
1818 array_equivalent , _maybe_convert_string_to_object ,
1919 is_categorical , needs_i8_conversion , is_datetimelike_v_numeric ,
20- is_internal_type )
20+ is_numeric_v_string_like , is_internal_type )
2121from pandas .core .dtypes import DatetimeTZDtype
2222
2323from 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):
10821082 # get the result, may need to transpose the other
10831083 def get_result (other ):
10841084
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 )
10871095
10881096 # mask if needed
10891097 if isinstance (values_mask , np .ndarray ) and values_mask .any ():
@@ -3214,7 +3222,7 @@ def get(self, item, fastpath=True):
32143222 else :
32153223
32163224 if isnull (item ):
3217- raise ValueError ("cannot label index with a null key" )
3225+ raise TypeError ("cannot label index with a null key" )
32183226
32193227 indexer = self .items .get_indexer_for ([item ])
32203228 return self .reindex_indexer (new_axis = self .items [indexer ],
@@ -4251,11 +4259,16 @@ def _possibly_compare(a, b, op):
42514259
42524260 # numpy deprecation warning to have i8 vs integer comparisions
42534261 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+
42554268 else :
4256- res = op (a , b )
4269+ result = op (a , b )
42574270
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 ):
42594272 type_names = [type (a ).__name__ , type (b ).__name__ ]
42604273
42614274 if is_a_array :
@@ -4265,7 +4278,7 @@ def _possibly_compare(a, b, op):
42654278 type_names [1 ] = 'ndarray(dtype=%s)' % b .dtype
42664279
42674280 raise TypeError ("Cannot compare types %r and %r" % tuple (type_names ))
4268- return res
4281+ return result
42694282
42704283
42714284def _concat_indexes (indexes ):
0 commit comments