Search code examples
pythonpandasdebuggingdataframevisual-studio-code

Pretty print a pandas dataframe in VS Code


I'd like to know if it's possible to display a pandas dataframe in VS Code while debugging (first picture) as it is displayed in PyCharm (second picture) ?

Thanks for any help.


df print in vs code:

df print in vs code

df print in pycharm:

df print in pycharm


Solution

  • As of the January 2021 release of the python extension, you can now view pandas dataframes with the built-in data viewer when debugging native python programs. When the program is halted at a breakpoint, right-click the dataframe variable in the variables list and select "View Value in Data Viewer"

    DataViewerWhenDebugging

    Edit July 2024 : As of June 2024, The built-in data viewer from jupyter extension is deprecated and no longer usable starting with Visual Studio Code 1.92 (see https://github.com/microsoft/vscode-jupyter/commit/8db6ecffccc9ddfdb84d4debfe2c1dcd7a1939e8) As replacement, it's possible to install the Data Wrangler extension for VSCode (https://code.visualstudio.com/docs/datascience/data-wrangler) to continue using the data viewer.