-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PR: Support Polars data frames in Variable Explorer #24558
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
Conversation
d43271b to
703587b
Compare
ccordoba12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great improvement, thanks @jitseniesen! Two tiny suggestions, the rest looks good to me.
Models can have a flags() function to override the behaviour of the base class, but the Qt classes for views do not have a flags() function.
Also add tests and add or improve docstrings.
If retrieving a variable from the kernel fails due to a ModuleNotFoundError raised by call_kernel(), then show an error message instructing the user to install the missing module in the console environment. This error occurs if a user tries to retrieve a Polars dataframe, because the kernel will transform it to a Pandas dataframe and this fails if pandas is not installed in the kernel environment.
…r-kernels.git --update external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "7987954c8" upstream: origin: "https://github.com/spyder-ide/spyder-kernels.git" branch: "master" commit: "7987954c8" git-subrepo: version: "0.4.9" origin: "https://github.com/ingydotnet/git-subrepo" commit: "30db3b8"
Apply suggestions from code review Co-authored-by: Carlos Cordoba <[email protected]>
|
@ccordoba12 Thanks for your suggestions. I committed them, updated the PR to incorporate the merged PR in spyder-kernels and rebased, so this is ready to be merged as far as I am concerned. |
ccordoba12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jitseniesen!
Description of Changes
Support Polars data frames in the Variable Explorer. The user can open the Polars dataframe in Spyder, in which case the kernel converts it to a Pandas dataframe. This is so that we don't need to have
polarsinstalled in Spyder's runtime environment, only in the console environment. The disadvantage is firstly that the data frame can not be edited in Spyder, because converting from Polars to Pandas and then back to Polars does probably not always work. Therefore, the dataframe editor is read only. Secondly, the conversion from Polars to Pandas in the console environment only works ifpandasandpyarroware installed in the console environment. Thus, I added a new error message to handle the case where opening an editor in the Variable Explorer raises anModuleNotFoundErrorin the kernel.Before this PR, Polars dataframes opened in the Object Explorer which is not very useful.
This PR requires spyder-ide/spyder-kernels#549.
Video of opening a Polars dataframe, when
polars,pandasandpyarroware installed in the console environment but onlypandasin the runtime environment:polars-with.mp4
Video of the error message shown if the user tries to open a Polars dataframe but
pyarrowis not installed in the console environment:polars-without.mp4
Issue(s) Resolved
Fixes #20281
Affirmation
By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.
I certify the above statement is true and correct:
Jitse Niesen