def _try_cast_result(self, result, dtype=None):
if dtype is None:<EOL><INDENT>dtype = self.dtype<EOL><DEDENT>if self.is_integer or self.is_bool or self.is_datetime:<EOL><INDENT>pass<EOL><DEDENT>elif self.is_float and result.dtype == self.dtype:<EOL><INDENT>if isinstance(dtype, str) and dtype == '<STR_LIT>':<EOL><INDENT>return result<EOL><DEDENT>if not isinstance(dtype, type):<EOL><INDENT>dtype = dtype.type<EOL><DEDENT>if issubclass(dtype, (np.bool_, np.object_)):<EOL><INDENT>if issubclass(dtype, np.bool_):<EOL><INDENT>if isna(result).all():<EOL><INDENT>return result.astype(np.bool_)<EOL><DEDENT>else:<EOL><INDENT>result = result.astype(np.object_)<EOL>result[result == <NUM_LIT:1>] = True<EOL>result[result == <NUM_LIT:0>] = False<EOL>return result<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return result.astype(np.object_)<EOL><DEDENT><DEDENT>return result<EOL><DEDENT>return maybe_downcast_to_dtype(result, dtype)<EOL>
try to cast the result to our original type, we may have
        roundtripped thru object in the mean-time