In this post I will show you how to access the Data viewer which is a useful tool to review, sort and filter data within a Pandas DataFrame.
Required VS Code Extension
If you have not already done so, add the Python extension for Visual Studio Code from Microsoft.

Code Sample
In the code example below, the English Premier League football is read from a HTML table into a list of DataFrames.
import pandas as pd
url = 'https://www.msn.com/en-au/sport/football/epl/ladder'
df_list = pd.read_html(url)
print(df_list[0])
The last line prints out the contents of the Dataframe. Pandas read_html returns a list so the print function is called and outputs the first and only entry in the list which is found at index 0.
Output via print()
Running the output using using print() gives a satisfactory output that is good enough for a first cut to review the data.

Data Viewer
It is also possible to view Pandas Datagrid with the more interactive Data Viewer. This feature is only available when running a program via the VS Code Debugger.
Step 1
Add a break point to the program by clicking in the gutter. In the example shown below I have added a breakpoint at line 7

Step 2
Start the debugger by clicking the debug icon on the side bar and then select Run and Debug

Step 3
Once the program hits the breakpoint, expand the df_list variable and right click where the red border is marked and then select View Value in Data Viewer

Step 4
With the Data Viewer visible, you can interact with the contents of the DataFrame with sort and filter operations.

Very nice! But is there an easier way?
Whilst the Data viewer is very useful, getting to it by having to run the debugger can be tiresome. If you are aware of a simpler or more elegant method of displaying the Data Viewer please let me know via the comments or by getting in touch.
Hi! In response to the call to leave a comment if there’s a more elegant way –
1. I work with files as Jupyter notebooks (ipnyb) instead of the .py extension.
2. Instead of typing print(df), I just type df on the next line and the output is very pretty.
Doesn’t allow for filtering like debug mode does, but I don’t see myself filtering all too much anyways, just getting a quick view. Eager to know what you think!
Perfect! I like it, I wouldn’t have thought of that.
I appreciate you taking the time to reply. Thank you.
For some reason when I right click on Dataframes in the Variables viewer while debugging VSCode no longer gives me the option to view the dataframe as you’ve described here. Do you know what could be causing the issue?
Thanks for getting in touch, unfortunately I haven’t seen this problem before. I appreciate you have already tried this but many times when VS Code does strange things a restart of VS Code has normally fixed the issue.
If you do solve it please let me know.
Regards
Ian