简体   繁体   English

仅执行大型 jupyter 笔记本中的一些单元格

[英]execute only some cells from a large jupyter notebook

I wanted to repeat an analysis included in a large jupyter notebook and save a couple of the generated dataframes in a csv file.我想重复一个大型 jupyter 笔记本中包含的分析,并将几个生成的数据帧保存在 csv 文件中。 My first attempt was to open the notebook in jupyter-lab and interactively run the cells I was interested, then add a new cell with my code that saves the relevant data to files.我的第一次尝试是在 jupyter-lab 中打开笔记本并以交互方式运行我感兴趣的单元格,然后使用我的代码添加一个新单元格,将相关数据保存到文件中。

I was wondering however if I could do the same thing with a script, eg run the 1st and 45th cell of the notebook and then run a few more commands to export the data.但是我想知道是否可以用脚本做同样的事情,例如运行笔记本的第 1 和第 45 个单元格,然后再运行一些命令来导出数据。

cell 0单元格 0

import IPython.display

cell 1单元格 1

x = 1

cell 2单元格 2

x = x + 1
print(x)

cell 3细胞 3

IPython.display.Javascript("Jupyter.notebook.execute_cells([2])")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM