def rtruediv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex: _sanitize_list_like(right) if not isinstance(right, numbers.Number): raise TypeError("True division can not be applied to given types.") def rtruediv(left: Column, right: Any) -> Column: return F.when(left == 0, SF.lit(np.inf).__div__(right)).otherwise( SF.lit(right).__truediv__(left)) right = transform_boolean_operand_to_numeric( right, spark_type=left.spark.data_type) return numpy_column_op(rtruediv)(left, right)
def floordiv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex: if not is_valid_operand_for_numeric_arithmetic(right): raise TypeError("Floor division can not be applied to given types.") def floordiv(left: Column, right: Any) -> Column: return F.when(SF.lit(right is np.nan), np.nan).otherwise( F.when( SF.lit(right != 0) | SF.lit(right).isNull(), F.floor(left.__div__(right)) ).otherwise(SF.lit(np.inf).__div__(left)) ) right = transform_boolean_operand_to_numeric(right, spark_type=left.spark.data_type) return numpy_column_op(floordiv)(left, right)
def rfloordiv(self, left: IndexOpsLike, right: Any) -> SeriesOrIndex: if not isinstance(right, numbers.Number): raise TypeError("Floor division can not be applied to given types.") def rfloordiv(left: Column, right: Any) -> Column: return F.when(SF.lit(left == 0), SF.lit(np.inf).__div__(right)).otherwise( F.when(SF.lit(left) == np.nan, np.nan).otherwise( F.floor(SF.lit(right).__div__(left)) ) ) right = transform_boolean_operand_to_numeric(right, spark_type=left.spark.data_type) return numpy_column_op(rfloordiv)(left, right)
def rtruediv(self, left, right) -> Union["Series", "Index"]: if isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if not isinstance(right, numbers.Number) or isinstance(right, bool): raise TypeError("division can not be applied to given types.") def rtruediv(left, right): return F.when(left == 0, F.lit(np.inf).__div__(right)).otherwise( F.lit(right).__truediv__(left)) return numpy_column_op(rtruediv)(left, right)
def rtruediv(self, left: T_IndexOps, right: Any) -> IndexOpsLike: if isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if not isinstance(right, numbers.Number): raise TypeError("division can not be applied to given types.") def rtruediv(left: Column, right: Any) -> Column: return F.when(left == 0, F.lit(np.inf).__div__(right)).otherwise( F.lit(right).__truediv__(left)) right = transform_boolean_operand_to_numeric(right, left.spark.data_type) return numpy_column_op(rtruediv)(left, right)
def rfloordiv(self, left, right) -> Union["Series", "Index"]: if isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if not isinstance(right, numbers.Number): raise TypeError("division can not be applied to given types.") def rfloordiv(left, right): return F.when(F.lit(left == 0), F.lit(np.inf).__div__(right)).otherwise( F.floor(F.lit(right).__div__(left))) right = transform_boolean_operand_to_numeric(right, left.spark.data_type) return numpy_column_op(rfloordiv)(left, right)
def truediv(self, left: T_IndexOps, right: Any) -> IndexOpsLike: if (isinstance(right, IndexOpsMixin) and isinstance( right.spark.data_type, StringType)) or isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if not is_valid_operand_for_numeric_arithmetic(right): raise TypeError("division can not be applied to given types.") right = transform_boolean_operand_to_numeric(right, left.spark.data_type) def truediv(left: Column, right: Any) -> Column: return F.when( F.lit(right != 0) | F.lit(right).isNull(), left.__div__(right)).otherwise(F.lit(np.inf).__div__(left)) return numpy_column_op(truediv)(left, right)
def truediv(self, left, right) -> Union["Series", "Index"]: if (isinstance(right, IndexOpsMixin) and isinstance( right.spark.data_type, StringType)) or isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if (isinstance(right, IndexOpsMixin) and (isinstance(right.dtype, CategoricalDtype) or (not isinstance(right.spark.data_type, NumericType))) ) and not isinstance(right, numbers.Number): raise TypeError("division can not be applied to given types.") def truediv(left, right): return F.when( F.lit(right != 0) | F.lit(right).isNull(), left.__div__(right)).otherwise(F.lit(np.inf).__div__(left)) return numpy_column_op(truediv)(left, right)
def floordiv(self, left, right) -> Union["Series", "Index"]: if (isinstance(right, IndexOpsMixin) and isinstance( right.spark.data_type, StringType)) or isinstance(right, str): raise TypeError( "division can not be applied on string series or literals.") if not is_valid_operand_for_numeric_arithmetic(right): raise TypeError("division can not be applied to given types.") right = transform_boolean_operand_to_numeric(right, left.spark.data_type) def floordiv(left, right): return F.when(F.lit(right is np.nan), np.nan).otherwise( F.when( F.lit(right != 0) | F.lit(right).isNull(), F.floor(left.__div__(right))).otherwise( F.lit(np.inf).__div__(left))) return numpy_column_op(floordiv)(left, right)