Coding tips
KeyError: 'x' in Python: 10 Causes and Fixes (dict, .get, JSON, pandas tips)
Python raises KeyError when you look up a missing key with square brackets. Here are 10 real causes, from a typo and nested JSON to pandas column labels, with the exact tracebacks from my tests and the fixes that stop the crash.