I imagine this has been covered but after numerous searches I’ve been unable to find an answer.
I’m trying to write some Python code and would like to see the Output of that code, like I would in a Jupyter Notebook, except in VSCode. To be clear I’m not looking to replicate the IN: / OUT: cells of a Jupyter Notebook, just have all my Python Code in the code pane and it’s output in the Output or Terminal Window.
For example if I run the following in Jupyter I see the contents of df, including the column names, the rows, info about the DF
import pandas as pd
df = pd.read_csv('test.csv')
df
If I run that same code in VSCode it defaults to the terminal window and I don’t see the df output even when clicking the output tab.
Thank you for your assistance.
2
Answers
To display text in a plain python file you need to use the print() function, unlike Jupyter Notebook where you can just call the variable name and it’ll display the variable, so in this instance you need to change:
to:
df = pd.read_csv(‘test.csv’)
print(df)
This new changed code uses the print function to display the value of the df variable.
If you want to see the dataframe output, you can use the
Debug Console
tab in VSCode.Assuming you have a python file with the contents shown in your description (the import and the
read_csv
line), here’s how you you would do it:Debug Console
Check an example below: