{
  "id": "data/parquet-decimal-overflow",
  "signature": "Parquet decimal precision overflow when reading into pandas",
  "signature_zh": "读取Parquet到pandas时十进制精度溢出",
  "regex": "(?:OverflowError|decimal.*overflow|precision.*loss|ArrowNotImplementedError.*decimal)",
  "domain": "data",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Parquet files store decimals with arbitrary precision (e.g., decimal(38,10)), but pandas converts them to float64 by default, causing overflow or precision loss for values exceeding float64 capacity.",
  "root_cause_type": "generic",
  "root_cause_zh": "Parquet文件以任意精度存储十进制数（例如decimal(38,10)），但pandas默认将其转换为float64，导致超过float64容量的值溢出或精度丢失。",
  "versions": [
    {
      "version": "pyarrow 12.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pyarrow 14.0.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "pandas 2.2.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This only preserves pandas-specific metadata like index names; it does not change the decimal-to-float conversion behavior.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The overflow already occurred during reading; the string representation will show the truncated/rounded value.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Fastparquet has the same limitation; it also converts decimals to float64 by default.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Read with pyarrow and specify decimal type: `import pyarrow.parquet as pq; table = pq.read_table('data.parquet'); from decimal import Decimal; df = table.to_pandas(types_mapper={pa.decimal128(38,10): Decimal})`",
      "success_rate": 0.9,
      "how": "Read with pyarrow and specify decimal type: `import pyarrow.parquet as pq; table = pq.read_table('data.parquet'); from decimal import Decimal; df = table.to_pandas(types_mapper={pa.decimal128(38,10): Decimal})`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use pandas read_parquet with dtype_backend='pyarrow': `df = pd.read_parquet('data.parquet', dtype_backend='pyarrow')`",
      "success_rate": 0.82,
      "how": "Use pandas read_parquet with dtype_backend='pyarrow': `df = pd.read_parquet('data.parquet', dtype_backend='pyarrow')`",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Read with pyarrow and specify decimal type: `import pyarrow.parquet as pq; table = pq.read_table('data.parquet'); from decimal import Decimal; df = table.to_pandas(types_mapper={pa.decimal128(38,10): Decimal})`",
    "Use pandas read_parquet with dtype_backend='pyarrow': `df = pd.read_parquet('data.parquet', dtype_backend='pyarrow')`"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://arrow.apache.org/docs/python/generated/pyarrow.parquet.read_table.html",
  "official_doc_section": null,
  "error_code": "ArrowNotImplementedError",
  "verification_tier": "ai_generated",
  "confidence": 0.83,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}