How to connect to an existing Jupyter Notebook kernel and inspect variables using the Variable explorer?

心不动则不痛 提交于 2019-12-02 02:41:51

问题


If I've got a kernel running through a Jupyter Notebook, I can easily connect to it from Spyder using Options > Connect to an exisisting kernel > Browse. Now I can get access to the Jupyter kernel and view the dataframe or any other variable by just running df:

Jupyter snippet:

#imports
import numpy as np
import pandas as pd

# Some sample data
np.random.seed(1234)
df = pd.DataFrame({'A1':np.random.normal(10, 1, 8),
                   'B1':np.random.normal(20, 2, 8)})

Spyder snippet:

df

# output:
          A1         B1
0  10.471435  20.031393
1   8.809024  15.514630
2  11.432707  22.300071
3   9.687348  21.983892
4   9.279411  21.906648
5  10.887163  15.957490
6  10.859588  19.331845
7   9.363476  20.004237

But why is the dataframe not available in the Variable Explorer in Spyder?


回答1:


(Spyder maintainer here) This happens because the kernels that are created by the notebook doesn't have the functionality necessary to display its namespace in our Variable Explorer.

And there's no easy workaround for that at the moment, sorry.



来源:https://stackoverflow.com/questions/55451965/how-to-connect-to-an-existing-jupyter-notebook-kernel-and-inspect-variables-usin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!