JoinRelationError(relation_name, table_name, repeated_key)
Source¶
Bases: NumdaplotError
Raised when a key appears several times in a Table of a join whose Relation expects it once.
For example, Relation.ONE_TO_MANY expects each key once in the left Table, the one joined.
Added in version 0.1.0
Parameters:
-
relation_name(str)The relation checked, such as
"Relation.ONE_TO_MANY". -
table_name(str)The Table holding the repeated key:
"the left Table"or"the right Table". -
repeated_key(RepeatedKey)The first repeated key, its values and its number of rows.
Attributes:
-
relation_nameThe relation checked.
-
table_nameThe Table holding the repeated key.
-
repeated_keyThe first repeated key, its values and its number of rows.
Examples:
import numdaplot as ndp
accidents = ndp.Table.from_arrays({"Num_Acc": ndp.Array.from_list([101, 101])})
users = ndp.Table.from_arrays({"Num_Acc": ndp.Array.from_list([101])})
try:
accidents.join(ndp.Join(other=users, keys=["Num_Acc"], relation=ndp.Relation.ONE_TO_MANY))
except ndp.JoinRelationError as error:
print(error)
# Expected each key of the left Table to appear once for Relation.ONE_TO_MANY, but 'Num_Acc' 101 appears 2 times.