Black Lives Matter. Please consider donating to Black Girls Code today.

Dash traceback not leading to any line in my code

I am working on my first Dash app. I am getting the following error:

"Cannot set a frame with no defined index "

The issue is that the traceback doesn’t lead to any line in my code. It only goes through installed libraries:

Traceback (most recent call last):
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\frame.py", line 3540, in _ensure_valid_index
    value = Series(value)
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\series.py", line 316, in __init__
    data = SingleBlockManager(data, index, fastpath=True)
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\managers.py", line 1516, in __init__
    block = make_block(block, placement=slice(0, len(axis)), ndim=1)
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 3284, in make_block
    return klass(values, ndim=ndim, placement=placement)
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 2792, in __init__
    super().__init__(values, ndim=ndim, placement=placement)
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\internals\blocks.py", line 128, in __init__
    "{mgr}".format(val=len(self.values), mgr=len(self.mgr_locs))
ValueError: Wrong number of items passed 3, placement implies 0

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\LIAG8802\Documents\Procurement_analytics\venv\lib\site-packages\pandas\core\frame.py", line 3543, in _ensure_valid_index
    "Cannot set a frame with no defined index "
ValueError: Cannot set a frame with no defined index and a value that cannot be converted to a Series

How can I know which line in my code is causing the error?

@vl2376
Can you share a snippet of your code, especially the pandas dataframe part.

It seems like the error is caused by the initialization of some Pandas object, probably because the data that you input is in a different format than what Pandas is expecting or because you are doing operations on an empty data frame.

You can debug the code line-by-line or (if you do not have a debugger) add print statements to help locating where the error arises.

@Emil

It seems that it was because I was trying to save an empty dataframe into my SQL table but what I am really interested in is this traceback issue. Unfortunately I cannot track the issue putting print s at several lines since the error pops out in the dash debug console, not in the anaconda console which does not crash.