MartinRinehart at gmail.com writes: > I don't understand what I don't understand in the following: I haven't tried to understand what your code is doing - but the NameError arises because you try to use Loc before its definition. Put the definition first and the error should go away.