{
  "id": "python/pandas-groupby-observed-warning",
  "signature": "FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas.",
  "signature_zh": "FutureWarning: observed=False 的默认值已被弃用，未来版本将改为 True。",
  "regex": "FutureWarning:\\ The\\ default\\ of\\ observed=False\\ is\\ deprecated\\ and\\ will\\ be\\ changed\\ to\\ True\\ in\\ a\\ future\\ version\\ of\\ pandas\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "groupby on a Categorical column with observed=False (default in older pandas) produces cartesian product of categories, including empty groups.",
  "root_cause_type": "generic",
  "root_cause_zh": "对 Categorical 列执行 groupby 且 observed=False（旧版 pandas 默认）会生成类别的笛卡尔积，包含空组。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Same warning, results include empty categories",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Loses categorical ordering",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "df.groupby('cat', observed=True).agg('sum')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "pd.set_option('mode.copy_on_write', True) plus explicit observed=True",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}