I am new to Jupyter notebooks based programming and I am looking for advice for best practices on how to make Jupyter code re-usable
Specifically, we have one notebook which preps and cleans a bunch of data into a pandas data frame, and then we run a lot of different experiments with that prepped data. Each of the experiments begins with a cell that starts with:
%run -i hh_data_prep.ipynb
This has worked Ok, BUT – as notebooks begin to pile up in our folder, I wanted to start organizing the notebooks in subdirectories, and here is where I’m running into trouble.
In a sub-directory, if I do something like this:
%run -i …/hh_data_prep.ipynb
Or use fancier ways to build the path, it never works right – Jupyter notebooks don’t seem to have a strong grasp of what directory they are in relative to other notebooks maybe? In my subdirectory, if I ask python to print out what directory it thinks we’re in, it prints out the directory above me Lol : (
Here is where I’m kind of begging for advice – I’m a newb and it’s entirely possible there’s something easy I’m just not grasping here – My questions to the community are basically:
A) Can you think of a way around the problem I’ve described?
B) Is there a better strategy for re-using code in Jupyter? Am I using a dumb, clunky approach where there is something better to do instead?
Thank You!! : )