相关疑难解决方法(0)

Ipython/Jupyter - 我们可以编程"运行上面的所有单元格"吗?

我正在使用带有python的jupyter 4,当发生崩溃时,我需要我的脚本执行"重新启动上面的所有单元格".可能吗 ?

第二个问题:如果我需要重新启动所有的单元格,我可以让python根据一些cell-id执行它们吗?然后我可以创建一个单元格id列表,在捕获异常时必须重新执行...

谢谢.

python jupyter

13
推荐指数
2
解决办法
5446
查看次数

如何遍历 Jupyter / iPython Notebook 中的多个单元格

我有一个 Jupyter Notebook,里面有几百行代码,分布在大约 30 个单元格中。如果我想遍历中间的 10 个单元格(例如使用 For 循环),你怎么做?是否有可能,或者您是否需要将循环中的所有代码合并到一个单元格中?

python jupyter-notebook

8
推荐指数
1
解决办法
2万
查看次数

Jupyter Notebook 循环单元

我有一个问题,是否可以在笔记本中的不同单元格中循环迭代?例如我有这个代码:

for c in range(2):
# Thetas
thetas = np.zeros((J,I))
it = np.nditer(thetas, flags=['multi_index'],op_flags=['writeonly'])
while not it.finished:
    i=it.multi_index[1]
    j=it.multi_index[0]
    coefs=np.array([1-(K/(prod[j]*la[j]*firm[i])),(-K/(prod[j]*firm[i]))*(1+(1/la[j])),-K/(prod[j]*firm[i])])
    sol=np.roots(coefs)
    it[0]=np.amax((sol))
    it.iternext()

# Wages
wag=np.zeros((J,I))
it = np.nditer(wag, flags=['multi_index'],op_flags=['writeonly'])
while not it.finished:
    i=it.multi_index[1]
    j=it.multi_index[0]
    it[0]=prod[j]*firm[i]-(K*(1+thetas[j,i])/(la[j]*thetas[j,i]))
    it.iternext()
Run Code Online (Sandbox Code Playgroud)

出于演示目的,我想在单元格中运行 thetas 代码,显示一些结果,然后运行工资,显示另一个结果,然后对 theta 和工资进行第二次迭代。这是可能吗?

谢谢

python ipython jupyter-notebook

5
推荐指数
0
解决办法
1万
查看次数

标签 统计

python ×3

jupyter-notebook ×2

ipython ×1

jupyter ×1