4 ms·
I use notebooks a lot but when I've got a piece of code that I re-use more than once I pull it out into a module or two. My notebooks are usually set up as: 1)
by Mvandenbergh 8y ago
I use notebooks a lot but when I've got a piece of code that I re-use more than once I pull it out into a module or two.
My notebooks are usually set up as:
1) a cell to load external libraries
2) a cell to load any of my own modules
3) a cell to set model parameters
4) a cell containing the functions that I use to load data (to be honest these are not always encapsulated in functions in the early stages of analysis)
5) cells containing functions that do stages of analysis that I'm happy with (but unique to this analysis and therefore not turned into modules).
6) A "main" cell that runs the cells in [5] and gets everything ready for
7) working cell[s] where I mess around with new analysis
While I'm working I only execute from [7] onwards unless I need to reload my data.
This is pretty easy to turn into production if needed because when the analysis is done, you can clean up the working cells and incorporate them into your main function.