rendner / py-plugin-dataframe-viewer

Plugin for JetBrains IDEs to view Python DataFrames when debugging.
https://plugins.jetbrains.com/plugin/16050-python-styled-dataframe-viewer
Apache License 2.0
13 stars 1 forks source link

Issue with View as Dataframe Polars #8

Closed 8DanB closed 8 months ago

8DanB commented 8 months ago

I cannot view a polars dataframe using "View as Styled Dataframe" when I try and view a polars dataframe outside of the debugger in Pycharm.

When using the debugger, it works fine. However, I have setup Pycharm to run code line-by-line using the plugin "Pycharm Smart Execute". When I try and view the Styled Dataframe nothing pops up with a polar dataframe.

rendner commented 8 months ago

Hi, can you please provide the following things for me so that I can have a look?

8DanB commented 8 months ago

PyCharm version: PyCharm 2023.3.3 (Community Edition) PyCharm Smart Execute: installed plugin 0.3.2 Guo Ci Python Styled DataFrameViewer: 0.14.0 cms.rendner polars: 0.20.7

Snippet: `import polars as pl

data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35], 'City': ['New York', 'San Francisco', 'Los Angeles']}

df = pl.DataFrame(data)

print(df) `

Description: Smart Execute allows me to run code line-by-line in Python, as opposed to using the debugger. I have keymaps setup so "CTRL + Enter" will "Execute cell in console, move to next code region" within the Settings -> Keymap section of Pycharm.

I am an R-user -- R studio has the functionality to run a line of code, inspect result, then another line, inspect, etc. I have been able to mirror this with Pycharm, however I am not able to view the Dataframe when I want to see it in the variable explorer.

rendner commented 8 months ago

Thank you very much. I have managed to reproduce the described behavior. The problem is independent of polars, it also exists for pandas.

My plugin requires an existing debugSession to work correctly. In your scenario the plugin can't get a debugSession. PyCharm returns null for XDebuggerManager.getInstance(project).currentSession.

The action Evaluate Expression, provided by PyCharm, is disabled in case no debugSession is available. I will also disable my View as Styled DataFrame action in this case so that it is clear to users.

Thank you for reporting the problem.

rendner commented 8 months ago

@8DanB I have released a new version (v0.15.0) that also works with the Python Console.