vs code Python extension dataframe not shown in output

Viewed 3944

I just started using jupyter cells in Visual Studio Code through the Python extension. It is outputting plots fine, but my dataframe is not showing up like the blog example from Microsoft. Below is my code I am running in VS Code:

#%%
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas as pd

x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()

#%%
d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)
df

My output looks like this:

VS Code Cell outputs

I am really excited to use jupyter in VS Code but I need to view the dataframes like in other variable explorers.

I am on windows using Anaconda as my environment.

  • jupyter=1.0.0=py36_7
  • jupyter_client=5.2.3=py36_0
  • jupyter_console=6.0.0=py36_0
  • jupyter_core=4.4.0=py36_0
  • numpy=1.15.4=py36h19fb1c0_0
  • pandas=0.23.4=py36h830ac7b_0
2 Answers

That error means we don't have the capability to render the df output for some reason.
The only thing I can think of is you might have a jupyter extension that's modifying the result of a df. (normally it returns an html table to us)

Do you know what jupyter extensions you have installed?

I uninstalled my Anaconda 3.6 and installed the newer Anaconda 3.7 and now it works in VS Code.

Related