django-debug-toolbar
django-debug-toolbar copied to clipboard
Bugfix for issue #910 raises error with pandas DataFrame objects
We are using debug-toolbar in a django project where we have DataFrame objects of pandas as items in the context_layer.
The pseudo cache code added to panel.py (e.g., around lines 97ff) breaks with DataFrame objects in context_layer.items(), because the 'if key_values in self.seen_layers' requires a comparison of key_values with all items in seen_layers, but DataFrame objects are not always so easy to compare without throwing an error.
Right now, we simply put a try-except statement in our local panel.py file(s), but it would be better to have a real patch in the django-debug-toolbar code for rollouts. I realize you could argue this is a pandas problem and not a debug-toolbar problem, but it still would be great for us to have some exception handling so Pandas does not simply kill the toolbar code.
Besides, thanks for this tool. We love it :) .
To clarify: In file debug_toolbar/panels/templates/panel.py, around line 97, we use now
key_values = sorted(context_layer.items())
try:
is_seen = key_values in self.seen_layers
except:
is_seen = False
if is_seen:
...
Not pretty, but works for us.
Just ran into the same issue, and I am not using a local version of toolbar which makes patching this a little harder.. (didn't look into monkeypatching it though)
👍 for me on this issue.
Running into the same issue on a pandas-heavy project.
Value Error: Can only compare identically-labeled Series objects
Edited source like @anotherzo suggested and it is working for now.
While I no longer have to edit the source with the latest update, I still periodically encounter this error.