def _arith_method_SERIES(cls, op, special):
str_rep = _get_opstr(op, cls)<EOL>op_name = _get_op_name(op, special)<EOL>eval_kwargs = _gen_eval_kwargs(op_name)<EOL>fill_zeros = _gen_fill_zeros(op_name)<EOL>construct_result = (_construct_divmod_result<EOL>if op in [divmod, rdivmod] else _construct_result)<EOL>def na_op(x, y):<EOL><INDENT>import pandas.core.computation.expressions as expressions<EOL>try:<EOL><INDENT>result = expressions.evaluate(op, str_rep, x, y, **eval_kwargs)<EOL><DEDENT>except TypeError:<EOL><INDENT>result = masked_arith_op(x, y, op)<EOL><DEDENT>result = missing.fill_zeros(result, x, y, op_name, fill_zeros)<EOL>return result<EOL><DEDENT>def safe_na_op(lvalues, rvalues):<EOL><INDENT>"""<STR_LIT>"""<EOL>try:<EOL><INDENT>with np.errstate(all='<STR_LIT:ignore>'):<EOL><INDENT>return na_op(lvalues, rvalues)<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>if is_object_dtype(lvalues):<EOL><INDENT>return libalgos.arrmap_object(lvalues,<EOL>lambda x: op(x, rvalues))<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>def wrapper(left, right):<EOL><INDENT>if isinstance(right, ABCDataFrame):<EOL><INDENT>return NotImplemented<EOL><DEDENT>left, right = _align_method_SERIES(left, right)<EOL>res_name = get_op_result_name(left, right)<EOL>right = maybe_upcast_for_op(right)<EOL>if is_categorical_dtype(left):<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>".format(typ=type(left).__name__, op=str_rep))<EOL><DEDENT>elif is_datetime64_dtype(left) or is_datetime64tz_dtype(left):<EOL><INDENT>result = dispatch_to_index_op(op, left, right, pd.DatetimeIndex)<EOL>return construct_result(left, result,<EOL>index=left.index, name=res_name,<EOL>dtype=result.dtype)<EOL><DEDENT>elif (is_extension_array_dtype(left) or<EOL>(is_extension_array_dtype(right) and not is_scalar(right))):<EOL><INDENT>return dispatch_to_extension_op(op, left, right)<EOL><DEDENT>elif is_timedelta64_dtype(left):<EOL><INDENT>result = dispatch_to_index_op(op, left, right, pd.TimedeltaIndex)<EOL>return construct_result(left, result,<EOL>index=left.index, name=res_name)<EOL><DEDENT>elif is_timedelta64_dtype(right):<EOL><INDENT>result = op(pd.Index(left), right)<EOL>return construct_result(left, result,<EOL>index=left.index, name=res_name,<EOL>dtype=result.dtype)<EOL><DEDENT>lvalues = left.values<EOL>rvalues = right<EOL>if isinstance(rvalues, ABCSeries):<EOL><INDENT>rvalues = rvalues.values<EOL><DEDENT>result = safe_na_op(lvalues, rvalues)<EOL>return construct_result(left, result,<EOL>index=left.index, name=res_name, dtype=None)<EOL><DEDENT>wrapper.__name__ = op_name<EOL>return wrapper<EOL>
Wrapper function for Series arithmetic operations, to avoid
code duplication.