[Solved] What are the thousands of lines in error in python


This is a stack trace. It shows not just where the actual error occurred directly, but also what the program was doing while it occurred.

  • The code df.loc['origin' == 'US'] (on line 6) is at the top of the trace, meaning it’s the root cause, but this by itself is not an error. This will evaluate 'origin' == 'US' to False, since this is a simple string comparison and the strings aren’t equal, and then it will evaluate df.loc[False].
  • Evaluating this requires looking up the key False in the object df.loc. This calls the __getitem__ method, which is called whenever you access a key using the syntax a[b].
  • The __getitem__ method has a line return self._getitem_axis(maybe_callable, axis=axis) calling a method named _getitem_axis. This is on line 1500 of the file.
  • The _getitem_axis method has a line return self._get_label(key, axis=axis), calling a method _get_label. This is line 1913 of the file.
  • …and so on…
  • Finally, the method pandas._libs.index.Int64Engine._check_type checks the type of the key. The key is False, which is of type bool. Presumably, this is not a valid type for the lookup you were doing, so the _check_type method raises a KeyError.

solved What are the thousands of lines in error in python