This looks a little brittle. Should try to use pandas date functionality wherever possible.