'How to understand an Index Error Message?

I am attempting to use the pretty-print confusion-matrix library to create a confusion matrix.

When I run pp_matrix(df, cmap=cmap), I get the following error message:

Traceback (most recent call last):
  File "/Users/name/folder/subfolder/subsubfolder/prepositions.py", line 27, in <module>
    pp_matrix(df, cmap=cmap)
  File "/opt/anaconda3/lib/python3.8/site-packages/pretty_confusion_matrix/pretty_confusion_matrix.py", line 222, in pp_matrix
    txt_res = configcell_text_and_colors(
  File "/opt/anaconda3/lib/python3.8/site-packages/pretty_confusion_matrix/pretty_confusion_matrix.py", line 59, in configcell_text_and_colors
    tot_rig = array_df[col][col]
IndexError: index 37 is out of bounds for axis 0 with size 37

The first few lines of my DateFrame look like this:

               in   auf   mit   zu  ...  an-entlang  auf-entlang  ohne  außerhalb
into          318     8    10    9  ...           0            0     0          0
in           4325   727   681   62  ...           0            0     0          0
on            253  3197   215   46  ...           0            0     0          0
at            206   280    54    9  ...           0            0     0          0
with          384   397  2097   24  ...           0            0     0          0
by             31    12    23    0  ...           0            0     0          0
in-front-of    15    15    25    0  ...           0            0     0          0

The total size is 49 rows x 36 columns.

I think the issue has to do with zero-indexing in Python, but to be honest, I'm not even sure how to go about debugging this.

Any suggestions would be greatly appreciated. Thank you in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source