Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TibbleGrouped object is not expandable in VSCode jupyter data viewer #79

Open
rleyvasal opened this issue Feb 22, 2022 · 9 comments
Open
Labels
3rd-party Issues due to 3rd-party packages/tools

Comments

@rleyvasal
Copy link
Collaborator

When I create grouped data with datar's group_by(), I get an undesirable DataFrameGroupBy element instead of a DataFrame. It is not desirable to have a DataFrameGroupBy in VSCode because the dataframe cannot be clicked on the Variables Window of VSCode to see the entire dataframe, whereas the mtcars can be click to exposed the full dataset because it is a DataFrame.

The code below creates grouped data in datar and grouped data in pandas; However, datar creates a DataFrameGroupBy instead of a dataframe.

from datar.all import *
from datar.datasets import mtcars
datar_group = mtcars >> group_by(f.hp) >> count()
pandas_group = mtcars.groupby('hp').size().reset_index().rename(columns = {0:"n"})

datar_group

@pwwang pwwang added the < v0.6 Issues with datar version prior to 0.6 label Feb 22, 2022
@pwwang
Copy link
Owner

pwwang commented Feb 22, 2022

Thanks for reporting.
That's a problem with the count() function.

Working on v0.6 to address all performance issues, and also the issue with the count function.
After its release, would you get back to this issue to see if the issue persists?

@rleyvasal
Copy link
Collaborator Author

sure, thanks for all your work on this project!

@pwwang
Copy link
Owner

pwwang commented Mar 7, 2022

Here is the behavior with 0.6.0:

image

image

count() is now maintaining the group structure, which is the desired behavior. See how it acts in R:

image

Feel free to try it out and let me know if there is any issues.

@rleyvasal
Copy link
Collaborator Author

Hi @pwwang,

Maybe I did not specify the functionality that I was expecting.

I was expecting to get a dataframe output after grouping data with group_by so that I could click on the icon on the left of the variable name in VSCode Variables(square with arrow pointing up) and open the dataframe in Data Viewer to explore the data( second Picture)

This is related with Data Viewer of dataframes and not related with the grouping functionality itself. Not sure if VSCode would add TibbleGroupd to Data Viewer to be able to see the data. Feel free to close this if you'd like.

Note: Variables window for pandas_group shows it is a Dataframe size 22,2 but datar_group shows is a TibbleGrouped size 22 (picture below)

datar_group_tibble

pandas_dat_group_on_Data_Viewer

@pwwang
Copy link
Owner

pwwang commented Mar 7, 2022

TibbleGrouped is a subclass of DataFrame, so you should be able to view it as a data frame in the viewer. That's why you have the data shown in your figure 2. Isn't that what you expected?

@rleyvasal
Copy link
Collaborator Author

rleyvasal commented Mar 7, 2022

figure 2 shows dataset grouped with pandas groupby() after click on the icon (square with arrow pointing up) on left of pandas_group variable name in Variables window.

datar_group grouped with datar's group_by() does not have the icon(square with arrow pointing up) next to it; therefore it cannot be clicked and viewed in Data Viewer window.
pandas_dat_group_on_Data_Viewer

@pwwang
Copy link
Owner

pwwang commented Mar 7, 2022

I see. Will give it a further investigation.

@pwwang pwwang removed the < v0.6 Issues with datar version prior to 0.6 label Mar 7, 2022
@pwwang pwwang changed the title group_by() creates unwanted DataFrameGroupBy TibbleGrouped object is not expandable in VSCode jupyter data viewer Mar 7, 2022
@pwwang
Copy link
Owner

pwwang commented Mar 7, 2022

I believe it's a problem with the data viewer. It's not recognizing an object of DataFrame subclass:

image

@pwwang
Copy link
Owner

pwwang commented Mar 7, 2022

An issue is submitted:

microsoft/vscode-jupyter#9264

@pwwang pwwang added the 3rd-party Issues due to 3rd-party packages/tools label Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party Issues due to 3rd-party packages/tools
Projects
None yet
Development

No branches or pull requests

2 participants