@classmethod<EOL><INDENT>def _create_method(cls, op, coerce_to_dtype=True):<DEDENT>
def _binop(self, other):<EOL><INDENT>def convert_values(param):<EOL><INDENT>if isinstance(param, ExtensionArray) or is_list_like(param):<EOL><INDENT>ovalues = param<EOL><DEDENT>else:  <EOL><INDENT>ovalues = [param] * len(self)<EOL><DEDENT>return ovalues<EOL><DEDENT>if isinstance(other, (ABCSeries, ABCIndexClass)):<EOL><INDENT>return NotImplemented<EOL><DEDENT>lvalues = self<EOL>rvalues = convert_values(other)<EOL>res = [op(a, b) for (a, b) in zip(lvalues, rvalues)]<EOL>def _maybe_convert(arr):<EOL><INDENT>if coerce_to_dtype:<EOL><INDENT>try:<EOL><INDENT>res = self._from_sequence(arr)<EOL><DEDENT>except Exception:<EOL><INDENT>res = np.asarray(arr)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>res = np.asarray(arr)<EOL><DEDENT>return res<EOL><DEDENT>if op.__name__ in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>a, b = zip(*res)<EOL>res = _maybe_convert(a), _maybe_convert(b)<EOL><DEDENT>else:<EOL><INDENT>res = _maybe_convert(res)<EOL><DEDENT>return res<EOL><DEDENT>op_name = ops._get_op_name(op, True)<EOL>return set_function_name(_binop, op_name, cls)<EOL>
A class method that returns a method that will correspond to an
operator for an ExtensionArray subclass, by dispatching to the
relevant operator defined on the individual elements of the
ExtensionArray.

Parameters
----------
op : function
    An operator that takes arguments op(a, b)
coerce_to_dtype :  bool, default True
    boolean indicating whether to attempt to convert
    the result to the underlying ExtensionArray dtype.
    If it's not possible to create a new ExtensionArray with the
    values, an ndarray is returned instead.

Returns
-------
Callable[[Any, Any], Union[ndarray, ExtensionArray]]
    A method that can be bound to a class. When used, the method
    receives the two arguments, one of which is the instance of
    this class, and should return an ExtensionArray or an ndarray.

    Returning an ndarray may be necessary when the result of the
    `op` cannot be stored in the ExtensionArray. The dtype of the
    ndarray uses NumPy's normal inference rules.

Example
-------
Given an ExtensionArray subclass called MyExtensionArray, use

>>> __add__ = cls._create_method(operator.add)

in the class definition of MyExtensionArray to create the operator
for addition, that will be based on the operator implementation
of the underlying elements of the ExtensionArray