in eland/series.py [0:0]
def _numeric_op(self, right: Any, method_name: str) -> "Series":
"""
return a op b
a & b == Series
a & b must share same Elasticsearch client, index_pattern and index_field
a == Series, b == numeric or string
Naming of the resulting Series
------------------------------
result = SeriesA op SeriesB
result.name == None
result = SeriesA op np.number
result.name == SeriesA.name
result = SeriesA op str
result.name == SeriesA.name
Naming is consistent for rops
"""
# print("_numeric_op", self, right, method_name)
if isinstance(right, Series):
# Check we can the 2 Series are compatible (raises on error):
self._query_compiler.check_arithmetics(right._query_compiler)
right_object = ArithmeticSeries(
right._query_compiler, right.name, right.dtype
)
display_name = None
elif np.issubdtype(np.dtype(type(right)), np.number):
right_object = ArithmeticNumber(right, np.dtype(type(right)))
display_name = self.name
elif isinstance(right, str):
right_object = ArithmeticString(right)
display_name = self.name
else:
raise TypeError(
f"unsupported operation type(s) [{method_name!r}] "
f"for operands ['{type(self)}' with dtype '{self.dtype}', "
f"'{type(right).__name__}']"
)
left_object = ArithmeticSeries(self._query_compiler, self.name, self.dtype)
left_object.arithmetic_operation(method_name, right_object)
series = Series(
_query_compiler=self._query_compiler.arithmetic_op_fields(
display_name, left_object
)
)
# force set name to 'display_name'
series._query_compiler._mappings.display_names = [display_name]
return series