0

Getting the following error:

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."

for the below code.

if (right_coordinate == shape['x']) | (left_coordinate == shape['x'] + shape['cx']):
Selcuk
  • 57,004
  • 12
  • 102
  • 110
  • A google search for your error sent me here: https://stackoverflow.com/questions/36921951/truth-value-of-a-series-is-ambiguous-use-a-empty-a-bool-a-item-a-any-o – Cireo Jul 21 '20 at 04:18
  • 2
    Try if (right_coordinate == shape['x']) or (left_coordinate == shape['x'] + shape['cx']) – Hayat Jul 21 '20 at 04:18
  • 2
    So which sense did you want? The options listed in the error message can give different answers. – gilch Jul 21 '20 at 04:21
  • | is the bitwise operator. You probably want the logical operator `or` – Garr Godfrey Jul 21 '20 at 04:22
  • `shape['x']` is a list of values. Do you want the comparison to be true if _any_ are true or if _all_ are true? That's the ambiguity. – tdelaney Jul 22 '21 at 03:29

0 Answers0