{
  "id": "python/pandas-keyerror-column-not-found",
  "signature": "KeyError: \"['column_name'] not in index\"",
  "signature_zh": "KeyError: \"['column_name'] 不在索引中\"",
  "regex": "KeyError:\\ \"\\['column_name'\\]\\ not\\ in\\ index\"",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Column name mismatch, often due to leading/trailing whitespace, case difference, or reading a CSV with a header offset so the expected column is actually a row value.",
  "root_cause_type": "generic",
  "root_cause_zh": "列名不匹配，通常由于前后空格、大小写差异，或读取 CSV 时 header 偏移导致期望的列实际是行值。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Same KeyError, column still absent",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returns None silently, downstream operations then crash",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "df.columns = df.columns.str.strip(); print(df.columns.tolist())",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pd.read_csv(path, skiprows=1) or header=0 to align headers",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-09",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}