Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code Data Viewer doesn't show DataFrame's index

I am starting to use VS Code for my notebooks and using the Data Viewer to explore my dataframes is one of the reasons. However, to my disappointment, the index doesn't really seem to show up in the Data Viewer.

Some code to reproduce:

d = {'index_col': ['foo', 'bar'], 'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)
df.set_index('index_col', inplace=True)

Gets me with this dataframe:

index_col col1 col2
foo 1 3
bar 2 4

What I see in VS Code's Data Viewer:

enter image description here

My "categorical" index has been replaced by what seems to be a numerical index / row number.

Is there a way (setting?) to have the data viewer showing me the index?

like image 828
danabb Avatar asked Mar 13 '26 22:03

danabb


1 Answers

@danabb. I believe that we have a bug open on this and a fix is in progress.

Issue: https://github.com/microsoft/vscode-jupyter/issues/5253 Fix PR in progress: https://github.com/microsoft/vscode-jupyter/pull/5254#pullrequestreview-619991659

This fix should be in our next major version release (roughly monthly).

like image 94
Ian Huff Avatar answered Mar 16 '26 13:03

Ian Huff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!