This is a follow up to the Tests 1 problem.
Now that you’ve got the code working it’s time to deal with the fact that it’s not really well structured (I mean, has this guy not heard of NumPy or Pandas or what), but before messing with working code let’s write a regression test. This test will make sure that the code still does the same thing it did before we started.
The problem is that all of the important code that needs refactoring is outside of functions at the bottom of the script. So,