microsoft / vscode-jupyter

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

Data viewer is not recognizing objects of `pandas.DataFrame` subclass #9264

Open pwwang opened 2 years ago

pwwang commented 2 years ago

Applies To

What happened?

A standard pandas data frame, which is an instance of pandas.DataFrame, is able to be expanded in the data viewer. However, an instance of pandas.DataFrame subclass is not.

image

VS Code Version

1.64.2

Jupyter Extension Version

v2022.1.1301854968

Jupyter logs

No response

Coding Language and Runtime Version

Python 3.9.5 (pandas 1.4.1)

Language Extension Version (if applicable)

Python v2022.2.1924087327

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Remote

DonJayamanne commented 2 years ago

We can fix this, instead of checking whether the type is dataframe we need to check if the type inherits dataframe. This information needs to come from Python instead of us trying to determine this in node based on the type value.

pwwang commented 2 years ago

@DonJayamanne Thanks! Should we submit an issue with the Python extension? I am not sure how it is supposed to work.

DonJayamanne commented 2 years ago

This is an issue in this extension, hence the issue belongs here.

rleyvasal commented 1 year ago

The issue still appears in the latest version of VSCode 1.75.1

DonJayamanne commented 9 months ago

Closing this issue as fixed, I just tested this and it works Please feel free to ping here with a sample code if this doesn't work, or feel free to create a new issue Here's what I tried

from pandas import DataFrame

class MyDF(DataFrame):
    ...

pd_df = DataFrame(dict(a=[1,2,3,4], b=[5,6,7,8]))
pd_df1 = MyDF(dict(a=[1,2,3,4], b=[5,6,7,8]))
rleyvasal commented 9 months ago

With the same code example @pw provided, I still don't see MyDF treated the same as a pandas DataFrame, there is an icon next to the name (highlighted in red) and Size appear to be different when inspecting Variables.

from pandas import DataFrame
class MyDF(DataFrame):
    ...
pd_df = DataFrame(dict(a=[1,2,3]))
my_df = MyDF(dict(a=[1,2,3]))
datar_dataframe_inheritance
DonJayamanne commented 1 month ago

I can still replicate this issue.