In response to your question regarding reusing code by importing.py files into notebooks, it is found that appending to the system path is the most successful method. This may make some people shudder, but it appears to be the cleanest way of importing code into a notebook without a pip -e install and a lot of module boilerplate.
With the above, one tip is to use the %autoreload and % aimport magics. Here's an illustration:
# Load the "autoreload" extension
%load_ext autoreload
# always reload modules marked with "%aimport"
%autoreload 1
import os
import sys
# add the 'src' directory as one where we can import modules
source_dir = os.path.join(os.getcwd(), os.pardir, 'src')
sys.path.append(source_dir)
# import my method from the source code
%aimport preprocess.build_features
Elevate your skills with our comprehensive Machine Learning Course.