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:

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?
@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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With