简体   繁体   English

如何使用不同的参数多次运行 jupyter notebook

[英]How to run jupyter notebook multiple times with different parameters

I prepared a jupyter notebook that is a python template for a report.我准备了一个 jupyter notebook,它是一个用于报告的 python 模板。 It displays pandas dataframes and plots some charts.它显示熊猫数据框并绘制一些图表。 After execution, I want to save it either in html or pdf format.执行后,我想将其保存为 html 或 pdf 格式。 In the first cell I initialize the variable month = 2 .在第一个单元格中,我初始化变量month = 2

My question is can I automatically make it run several times for months from collection [1,2,5,6] and store each execution as a html file?我的问题是我可以自动让它从集合[1,2,5,6]中运行几个月并将每次执行存储为 html 文件吗?

I would advise to put the code that generates the report inside a function.我建议将生成报告的代码放在函数中。 Then call the function from a loop.然后从循环中调用该函数。 Which loops over an array of the different parameters you want to pass along each report.哪个循环遍历您要在每个报告中传递的不同参数的数组。 Then you just run your notebook once.然后你只需运行你的笔记本一次。

Otherwise pass the parameters to your notebook described here: Passing command line arguments to argv in jupyter/ipython notebook否则将参数传递到此处描述的笔记本:将命令行参数传递给 jupyter/ipython 笔记本中的 argv

and then export to html like so: https://stackoverflow.com/a/38909626/9268396然后像这样导出到html: https ://stackoverflow.com/a/38909626/9268396

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

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