microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.28k stars 289 forks source link

Dataviewer not showing variables when columns are multi-indexed #11677

Open riotwhale opened 1 year ago

riotwhale commented 1 year ago

Environment data

Expected & Actual behaviour

When multi-indexing is applied to a dataframe, it will display() correctly inline, however if you double click on the variable from the Jupyter: Variables toolbar then it wont render. In the code below df2 and 3 wont render.

EDIT: Just to clarify the code below with df2 and 3 is provided to check it wasnt caused by having a multi-index level being blank.

Steps to reproduce:


import pandas as pd
df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD'))

display(df)

df2 = df.copy()

try:
    df2.columns = pd.MultiIndex.from_product([df2.columns, ['']])
except: 
    display("Columns already multi-indexed")

display(df2)

df3 = df2.copy()

df3.columns = pd.MultiIndex.from_tuples(
    [
        ("A", 0),
        ("A", 1),
        ("A", 2),
        ("A", 3),
    ]
)

display(df3)
amunger commented 1 year ago

thanks for the repro case, confirmed I see the same behavior

IanMatthewHuff commented 1 year ago

Dupe of #5551

YishGene commented 1 year ago

I'm still seeing this problem in the jupter extension v2023.1.1003441034.

I copied the above code snippet by the OP and see this in the Data Viewer:

image
sunrisewestern commented 1 year ago

Dupe of #5551

@IanMatthewHuff I don't think it's Dupe of #5551. The problem is not incorrect index showing, it's that the whole data frame itself won't show as indicated by @YishGene.

YishGene commented 1 year ago

Dupe of #5551

@IanMatthewHuff right, I don't think it's Dupe of #5551. The problem is not incorrect index showing, it's that the whole data frame itself won't show as indicated by @YishGene.

@IanMatthewHuff is right, I looked at #5551 (quoted in the earlier messages) but it's not the same thing.

VEFM02 commented 7 months ago

I'm still reproducing this error, I can't see multi-indexed dataframes in data viewer while debugging.