3

I have a notebook, which can do some complex data analysis with one dataset. At the end, it saves the notebook and converts into HTML, so I can view the result later without running the notebook again. One example is this:

https://cdn.rawgit.com/cqcn1991/Wind-Speed-Analysis/master/output_HTML/marham.html

Now, I want to run the notebook over many, different datasets. How can I do it?

Maybe something like

files = [
'./data/NCDC/cn/binhai/dat.txt', 
'./data/NCDC/cn/luogang/dat.txt',
"./data/NCDC/cn/tianjing/dat.txt", 
"./data/NCDC/cn/gushi/dat.txt", 
"./data/NCDC/cn/yueyang/dat.txt", 
]
for input_file_path in files:
    run_notebook('GMM.ipynb', input_file_path)

My thougths:

  1. I find Run parts of a ipython notebook in a loop / with different input parameter, but it's run part of the cells within the notebook.

  2. Scientific Computing & Ipython Notebook: How to organize code? provides a solution to run notebook within a host notebook. However, it's not that the target notebook gets runned, but the target notebook's code run within the host's environment. That leaves the original notebook un-changed, and when saving into HTML, the results are all the same.

Community
  • 1
  • 1
ZK Zhao
  • 19,885
  • 47
  • 132
  • 206
  • 1
    [nbparameterise](https://github.com/takluyver/nbparameterise) is one take on this. – Thomas K Aug 20 '16 at 23:09
  • @ThomasK this is very creative. Why didn't see it be used by others? – ZK Zhao Aug 21 '16 at 00:25
  • Thanks! I haven't promoted it very much, it's got a really awkward name, and it's kind of hard to explain quickly what it is. ;-) – Thomas K Aug 21 '16 at 11:55
  • @ThomasK I'd say currently the SciPy community lacks a way to promote additive and productive works. Yours is an example, and so is my involvement in [toc2](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/toc2). – ZK Zhao Aug 21 '16 at 12:15
  • @ThomasK I think a framework like `Ruby on Rails` would be helpful to promote these best practices and also keep the original Scipy/Jupyter Notebook code repo lean. – ZK Zhao Aug 21 '16 at 12:17
  • I'm not quite sure what you mean. We have many web frameworks; Django is most often likened to Ruby on Rails, while Jupyter uses Tornado. Do you mean we should build a website to help people discover useful tools? – Thomas K Aug 23 '16 at 06:52

0 Answers0