{
  "id": "python/numpy-visible-deprecation-ragged",
  "signature": "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.",
  "signature_zh": "ValueError: 用序列设置数组元素。在 1 维之后请求的数组形状不均匀。检测到的形状为 (3,) + 不均匀部分。",
  "regex": "ValueError:\\ setting\\ an\\ array\\ element\\ with\\ a\\ sequence\\.\\ The\\ requested\\ array\\ has\\ an\\ inhomogeneous\\ shape\\ after\\ 1\\ dimensions\\.\\ The\\ detected\\ shape\\ was\\ \\(3,\\)\\ \\+\\ inhomogeneous\\ part\\.",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "np.array() called on a list of lists with differing lengths. Since NumPy 1.24 this raises instead of creating an object array.",
  "root_cause_type": "generic",
  "root_cause_zh": "对长度不一致的列表的列表调用 np.array()。自 NumPy 1.24 起会报错而不是创建 object 数组。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Still cannot broadcast ragged data",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "np.stack requires identical shapes too",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "np.array(data, dtype=object) to explicitly request an object array",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Pad sequences first: from itertools import zip_longest; np.array(list(zip_longest(*data, fillvalue=0))).T",
      "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-02-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}