django-debug-toolbar icon indicating copy to clipboard operation
django-debug-toolbar copied to clipboard

Bugfix for issue #910 raises error with pandas DataFrame objects

Open anotherzo opened this issue 6 years ago • 4 comments

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 :) .

anotherzo avatar Apr 12 '18 12:04 anotherzo

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.

anotherzo avatar May 15 '18 18:05 anotherzo

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.

flinz avatar Oct 15 '18 15:10 flinz

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.

iamjonmiller avatar Mar 18 '19 23:03 iamjonmiller

While I no longer have to edit the source with the latest update, I still periodically encounter this error.

iamjonmiller avatar Sep 19 '19 21:09 iamjonmiller