IncompatibleTypesError(operation, type_names)
Source¶
Bases: NumdaplotError
Raised when an operation, a rule, a statistic or a math function does not apply to the types it receives.
For example, a number cannot be added to a text, and Contains only applies to text.
Added in version 0.1.0
Parameters:
-
operation(str)Name of the operation: an operator such as
"+", or a rule, statistic or function name. -
type_names(list[str])Names of the
ndp.Typemembers the operation received, in order.
Attributes:
-
operationName of the operation: an operator such as
"+", or a rule, statistic or function name. -
type_namesNames of the
ndp.Typemembers the operation received, in order. -
column_name(str | None)Name of the Table column holding the first type, or
Nonefor an Array or a type alone.
Examples:
import numdaplot as ndp
array = ndp.Array.from_list([1, 2])
try:
array + "euros"
except ndp.IncompatibleTypesError as error:
print(error)
# Cannot apply + to INT64 and TEXT.
sales = ndp.Table.from_arrays({"city": ndp.Array.from_list(["Paris"])})
mean_city = ndp.Calculation(column="city", function=ndp.Mean())
try:
sales.aggregate(ndp.Aggregation(calculations=[mean_city]))
except ndp.IncompatibleTypesError as error:
print(error)
# Cannot apply Mean to the TEXT column 'city'.