{
  "id": "python/matplotlib-date-parser-error",
  "signature": "ValueError: Date ordinal 737791 is not a valid date for the Gregorian calendar.",
  "signature_zh": "ValueError: 日期序数737791不是公历中的有效日期。",
  "regex": "ValueError:\\ Date\\ ordinal\\ 737791\\ is\\ not\\ a\\ valid\\ date\\ for\\ the\\ Gregorian\\ calendar\\.",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Using matplotlib's date2num or num2date with an out-of-range ordinal, often due to incorrect conversion of dates before year 1 or after year 9999.",
  "root_cause_type": "generic",
  "root_cause_zh": "使用matplotlib的date2num或num2date时，传入的序数超出范围，通常是由于转换了公元1年之前或9999年之后的日期。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Ignoring the error and continuing",
      "why_fails": "The plot may be incorrect or missing data points.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using a different date library like datetime",
      "why_fails": "The error is in matplotlib's conversion; datetime may still produce valid ordinals but the issue is with the range.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure dates are within the Gregorian calendar range (year 1 to 9999)",
      "success_rate": 0.9,
      "how": "from datetime import datetime; date = datetime(2024, 1, 1); ordinal = matplotlib.dates.date2num(date)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use pandas date handling before plotting",
      "success_rate": 0.85,
      "how": "import pandas as pd; dates = pd.date_range('2024-01-01', periods=10); plt.plot_date(dates, values)",
      "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.83,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}