The # Load your CSV once: section will need to be in a Both code component.
Move your function definitions to Before Experiment