otp.Operation.float.cmp#

cmp(other, eps)#

Compare two double values between themselves according to eps relative difference.

This function returns 0 if column = other, 1 if column > other, and -1 if column < other. Two numbers are considered to be equal if both of them are NaN or abs(column - other) / (abs(column) + abs(other)) < eps. In other words, eps represents a relative difference (percentage) between the two numbers, not an absolute difference.

Parameters
Returns

result – 0 if column == other, 1 if column > other, and -1 if column < other.

Return type

Operation

Examples

>>> data = otp.Ticks(X=[1, 2.17, 10.31841, 3.141593, 6],
...                  OTHER=[1.01, 2.1, 10.32841, 3.14, 5],
...                  EPS=[0, 1, 0.1, 0.001, 0.001])
>>> data["X"] = data["X"].float.cmp(data["OTHER"], data["EPS"])
>>> data = otp.run(data)
>>> data["X"]
0   -1.0
1    0.0
2    0.0
3    0.0
4    1.0
Name: X, dtype: float64

See also

eq