datar
datar copied to clipboard
`TibbleGrouped` object is not expandable in VSCode jupyter data viewer
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"})
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?
sure, thanks for all your work on this project!
Here is the behavior with 0.6.0:


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

Feel free to try it out and let me know if there is any issues.
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)
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?
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.
I see. Will give it a further investigation.
I believe it's a problem with the data viewer. It's not recognizing an object of DataFrame subclass:

An issue is submitted:
https://github.com/microsoft/vscode-jupyter/issues/9264