Regarding keyerror: 2

10 views
Skip to first unread message

Lenka Saikumar

unread,
Oct 27, 2025, 2:03:08 AMOct 27
to SWAT-MODFLOW

Hi everyone,

i got error while visualize the results in hydrology tab. please give suggestions how to resolve this error.


2025-10-27T10:42:23     WARNING    Traceback (most recent call last):
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc
              return self._engine.get_loc(casted_key)
              File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc
              File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc
              File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
              File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
             KeyError: 2
             
             The above exception was the direct cause of the following exception:
             
             Traceback (most recent call last):
              File "C:\Users/lab/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\QSWATMOD2.py", line 1077, in plot_stf
              post_i_sw.plot_stf(self, ts)
              File "C:\Users/lab/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\pyfolder\post_i_sw.py", line 111, in plot_stf
              plot_simulated(self, ax, wd, subnum, startDate, ts)
              File "C:\Users/lab/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\QSWATMOD2\pyfolder\post_i_sw.py", line 155, in plot_simulated
              df = output_rch.loc[subnum]
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\indexing.py", line 1103, in __getitem__
              return self._getitem_axis(maybe_callable, axis=axis)
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\indexing.py", line 1343, in _getitem_axis
              return self._get_label(key, axis=axis)
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\indexing.py", line 1293, in _get_label
              return self.obj.xs(label, axis=axis)
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\generic.py", line 4095, in xs
              loc = index.get_loc(key)
              File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc
              raise KeyError(key) from err
             KeyError: 2


Thanks in advance!


Seonggyu Park

unread,
Dec 16, 2025, 10:58:24 PM (22 hours ago) Dec 16
to SWAT-MODFLOW
Hi,

Could you please check the simulation ran successfully? If your model ran successfully, please share your QSWATMOD project folder and GIS file.
I’ll take a look and get back to you.

Thanks,
Seonggyu
Reply all
Reply to author
Forward
0 new messages