Beispiel #1
0
 def safe_na_op(lvalues, rvalues):
     try:
         return na_op(lvalues, rvalues)
     except Exception:
         if isinstance(rvalues, ABCSeries):
             if is_object_dtype(rvalues):
                 # if dtype is object, try elementwise op
                 return _algos.arrmap_object(rvalues, lambda x: op(lvalues, x))
         else:
             if is_object_dtype(lvalues):
                 return _algos.arrmap_object(lvalues, lambda x: op(x, rvalues))
         raise
Beispiel #2
0
 def map(self, f):
     try:
         result = f(self)
         if not isinstance(result, (np.ndarray, Index)):
             raise TypeError
         return result
     except Exception:
         return _algos.arrmap_object(self.asobject.values, f)
Beispiel #3
0
 def map(self, f):
     try:
         result = f(self)
         if not isinstance(result, (np.ndarray, Index)):
             raise TypeError
         return result
     except Exception:
         return _algos.arrmap_object(self.asobject.values, f)
Beispiel #4
0
def test_arrmap():
    values = np.array(['foo', 'foo', 'bar', 'bar', 'baz', 'qux'], dtype='O')
    result = algos.arrmap_object(values, lambda x: x in ['foo', 'bar'])
    assert(result.dtype == np.bool_)
Beispiel #5
0
 def map(self, f):
     try:
         return f(self)
     except:
         values = self._get_object_array()
         return _algos.arrmap_object(values, f)
Beispiel #6
0
def test_arrmap():
    values = np.array(['foo', 'foo', 'bar', 'bar', 'baz', 'qux'], dtype='O')
    result = algos.arrmap_object(values, lambda x: x in ['foo', 'bar'])
    assert (result.dtype == np.bool_)
Beispiel #7
0
 def map(self, f):
     try:
         return f(self)
     except:
         values = self._get_object_array()
         return _algos.arrmap_object(values, f)
Beispiel #8
0
def test_arrmap():
    values = np.array(["foo", "foo", "bar", "bar", "baz", "qux"], dtype="O")
    result = algos.arrmap_object(values, lambda x: x in ["foo", "bar"])
    assert result.dtype == np.bool_