question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variable explorer show none for last level in row multiindex

See original GitHub issue

Description

What steps will reproduce the problem?

import pandas as pd import numpy as np

my_df = pd.DataFrame([[1,1,1,1],[1,1,1,1],[1,1,1,1]],columns=[‘a’,‘b’,‘c’,‘d’]) my_df = my_df.groupby([‘a’,‘b’]).agg({‘c’:[sum] ,‘d’:[max] })

my_df2 = pd.DataFrame([[1,1,1,1],[1,1,1,1],[1,1,1,1]],columns=[‘a’,‘b’,‘c’,‘d’]) my_df2 = my_df2.groupby([‘a’,‘b’,‘c’]).agg({‘d’:[max] })

When a dataframe has multiindex in both rows and columns, variable explorer shows None for the last level of rows’ multiindex. Regardless the number of levels.

Hypothesys: either last value of rows’ index is not being read, either it is being treated as a colunm?

Versions

  • Spyder version: 4.1.5
  • Python version: 3.8.5
  • Qt version: 5.9.7
  • PyQt5 version: 5.9.2
  • Operating System: Windows 10

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.18.1 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
paramiko >=2.4.0               :  2.7.2 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.6 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  None (OK)
matplotlib >=2.0.0             :  3.3.1 (OK)
numpy >=1.7                    :  1.19.1 (OK)
pandas >=0.13.1                :  1.1.1 (OK)
scipy >=0.17.0                 :  1.5.0 (OK)
sympy >=0.7.3                  :  None (OK)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eduardosuelacommented, Sep 28, 2020

@andfoy not sure, maybe aggregating the data causes the index to not have a label? We will need to check further to see if there is actually a label to show instead of the None

I have check the multiindexes with python code and both have values It seems a problem with the visualization itself

0reactions
eduardosuelacommented, Sep 28, 2020

Hi @eduardosuela, thanks for reporting this issue, does this screenshot reproduces your problem?

imagen

@dalthviz, do you know if this is expected?

Yes that’s exactly what happens

I have thought about the problem Maybe the labels should be at the places where Index 0, Index 1 … that way they wouldn’t be competing for that “small matrix”. The last cell will always be not enough to hold the value of both rows and cols

Read more comments on GitHub >

github_iconTop Results From Across the Web

Confused by Multi-Index in Pandas? 9 Essential Operations to ...
1. What's MultiIndex? We have mentioned that single level index uses a series of labels to uniquely identify each row or column. Unlike...
Read more >
How to find difference between rows in a pandas multiIndex ...
Assigning the first grouping to result variable: result = df.groupby(['A','B']).sum(). You could use a pipe operation with nth:
Read more >
How do I use the MultiIndex in pandas? - YouTube
One of the most powerful features in pandas is multi- level indexing (or "hierarchical indexing"), which allows you to add extra dimensions ...
Read more >
Variable Explorer — Spyder 5 documentation
The Variable Explorer allows you to interactively browse and manage the objects generated running your code. Spyder Variable Explorer execution with a variable ......
Read more >
What's New — pandas 0.18.0 documentation - PyData |
Check the API Changes and deprecations before updating. ... loses column names for MultiIndexes (GH11600); Bug in DataFrame.round() with non-unique column ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found