{
  "id": "python/pandas-merge-dtype-mismatch",
  "signature": "ValueError: You are trying to merge on int64 and object columns. If you wish to proceed you should use pd.concat",
  "signature_zh": "ValueError: 您正尝试在 int64 和 object 列上合并。如要继续请使用 pd.concat",
  "regex": "ValueError:\\ You\\ are\\ trying\\ to\\ merge\\ on\\ int64\\ and\\ object\\ columns\\.\\ If\\ you\\ wish\\ to\\ proceed\\ you\\ should\\ use\\ pd\\.concat",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "pd.merge requires matching dtypes on join keys. A CSV read without explicit dtype inference often leaves IDs as object (string) in one frame and int in the other.",
  "root_cause_type": "generic",
  "root_cause_zh": "pd.merge 要求连接键的 dtype 匹配。未显式指定 dtype 读取的 CSV 常使一个 DataFrame 的 ID 为 object（字符串），另一个为 int。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Same ValueError",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Changes dtype but breaks numeric comparisons downstream",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "df2['id'] = df2['id'].astype(df1['id'].dtype); pd.merge(df1, df2, on='id')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Read both with pd.read_csv(..., dtype={'id': 'int64'})",
      "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.89,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-25",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}