Skip to content

Bugfix for issue #910 raises error with pandas DataFrame objects #1053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
anotherzo opened this issue Apr 12, 2018 · 4 comments
Open

Bugfix for issue #910 raises error with pandas DataFrame objects #1053

anotherzo opened this issue Apr 12, 2018 · 4 comments

Comments

@anotherzo
Copy link

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
Copy link
Author

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.

@seeholza
Copy link

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.

@iamjonmiller
Copy link

iamjonmiller commented Mar 18, 2019

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants