KeyError when duplicating table

Actually, I think this was just a symptom of the other issue I posted here. Because it only happened with the data that was imported incorrectly.