Viewing Pandas DataFrame in VS Code

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 = ''

df_list = pd.read_html(url)


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.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.