{"record":{"id":"ace022f8bc10c601","repo":"OpenBB-finance/OpenBB","slug":"error-maturity-column-not-found-in-the-data","errorCode":null,"errorMessage":"Error: Maturity column not found in the data.","messagePattern":"Error: Maturity column not found in the data\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_views.py","lineNumber":47,"sourceCode":"        from pandas import DataFrame\n\n        data = kwargs.get(\"data\")\n        df: DataFrame = DataFrame()\n        if data:\n            if isinstance(data, DataFrame) and not data.empty:  # noqa: SIM108\n                df = data\n            elif isinstance(data, (list, Data)):\n                df = basemodel_to_df(data, index=None)  # type: ignore\n            else:\n                pass\n        else:\n            df = DataFrame([d.model_dump() for d in kwargs[\"obbject_item\"]])  # type: ignore\n\n        if df.empty:\n            raise ValueError(\"Error: No data to plot.\")\n\n        if \"maturity\" not in df.columns:\n            raise ValueError(\"Error: Maturity column not found in the data.\")\n\n        if \"rate\" not in df.columns:\n            raise ValueError(\"Error: Rate column not found in the data.\")\n\n        if \"date\" not in df.columns:\n            raise ValueError(\"Error: Date column not found in the data.\")\n\n        provider = kwargs.get(\"provider\")\n        df[\"date\"] = df[\"date\"].astype(str)\n        maturities = duration_sorter(df[\"maturity\"].unique().tolist())\n        countries: list = (\n            df[\"country\"].unique().tolist() if \"country\" in df.columns else []\n        )\n\n        # Use the supplied colors, if any.\n        colors = kwargs.get(\"colors\", [])\n        if not colors:\n            colors = LARGE_CYCLER","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/fixedincome/openbb_fixedincome/fixedincome_views.py#L29-L65","documentation":"The fixed-income rate-curve chart requires a 'maturity' column to sort tenors with its duration sorter and build the curve's x-axis. After the empty-data check, a frame without 'maturity' raises ValueError('Error: Maturity column not found in the data.'), meaning the payload parsed but is not rate-curve-shaped data.","triggerScenarios":"Charting a fixedincome endpoint response that lacks per-tenor maturity rows (e.g. spot/par rates keyed differently); injecting a custom DataFrame with tenors named 'tenor' or 'term' instead of 'maturity'.","commonSituations":"Renaming columns during preprocessing, charting a non-curve fixedincome dataset (e.g. forecasting or custom rates) through the curve view, or provider schema changes dropping the maturity field.","solutions":["Chart the actual curve endpoints (obb.fixedincome.government.curve) whose models include maturity, rate, date.","Rename injected columns: df = df.rename(columns={'tenor': 'maturity'}) and ensure 'rate' and 'date' also exist (they are checked next).","Check res.to_df().columns before calling the chart to confirm maturity/rate/date are present."],"exampleFix":"# before\nfig = views.fixedincome_curve(data=df)  # df has 'tenor' instead of 'maturity'\n\n# after\ndf = df.rename(columns={'tenor': 'maturity'})\nfig = views.fixedincome_curve(data=df)","handlingStrategy":"validation","validationCode":"required = {'maturity', 'rate', 'date'}\ndf = res.to_df() if hasattr(res, 'to_df') else data\nmissing = required - set(df.columns)\nassert not missing, f'curve chart missing columns: {sorted(missing)}'","typeGuard":"def has_curve_columns(df) -> bool:\n    \"\"\"True when the frame carries maturity, rate, and date columns.\"\"\"\n    return {'maturity', 'rate', 'date'}.issubset(getattr(df, 'columns', []))","tryCatchPattern":"try:\n    fig = views.fixedincome_curve(data=df)\nexcept ValueError as e:\n    if 'Maturity column not found' in str(e):\n        fig = views.fixedincome_curve(data=df.rename(columns={'tenor': 'maturity'}))\n    else:\n        raise","preventionTips":["Rename tenor/term columns to 'maturity' before injecting custom curve data.","Only route genuine curve datasets (maturity/rate/date) through the curve view.","Check df.columns once when integrating a new provider."],"tags":["fixedincome","charting","column-missing","yield-curve"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}