etna.transforms.BinaryOperator#

class BinaryOperator(value)[source]#

Bases: str, Enum

Enum for mathematical operators from pandas.

Methods

perform(df, left_operand, right_operand, ...)

Perform binary operation on passed dataframe.

Attributes

add

"+"

sub

"-"

mul

"*"

div

"/"

floordiv

"//"

mod

"%"

pow

"**"

eq

"=="

ne

"!="

le

"<="

lt

"<"

ge

">="

gt

">"

perform(df: DataFrame, left_operand: str, right_operand: str, out_column: str) DataFrame[source]#

Perform binary operation on passed dataframe.

  • If during the operation a division by zero of a positive number occurs, writes +inf to this cell of the column, if negative - -inf, if 0/0 - nan.

  • In the case of raising a negative number to a non-integer power, writes nan to this cell of the column.

Parameters:
  • df (DataFrame) – Source Dataframe

  • left_operand (str) – Name of the left column

  • right_operand (str) – Name of the right column

  • out_column (str) – Resulting column name, which contains the result of the operation operand(left, right)

Returns:

Column which contains result of operation

Return type:

DataFrame

add = '+'[source]#

“+”

Type:

Add operation, value

div = '/'[source]#

“/”

Type:

Division operation, value

eq = '=='[source]#

“==”

Type:

Equal operation, value

floordiv = '//'[source]#

“//”

Type:

Floordivision operation, value

ge = '>='[source]#

“>=”

Type:

Greater or equal operation, value

gt = '>'[source]#

“>”

Type:

Greater operation, value

le = '<='[source]#

“<=”

Type:

Less or equal operation, value

lt = '<'[source]#

“<”

Type:

Less operation, value

mod = '%'[source]#

“%”

Type:

Module operation, value

mul = '*'[source]#

“*”

Type:

Multiplication operation, value

ne = '!='[source]#

“!=”

Type:

Not operation, value

pow = '**'[source]#

“**”

Type:

Pow operation, value

sub = '-'[source]#

“-”

Type:

Subtraction operation, value