{"record":{"id":"0c9e05d25aa967d2","repo":"OpenBB-finance/OpenBB","slug":"failed-to-convert-results-to-chart-ensure-the-pro","errorCode":null,"errorMessage":"Failed to convert results to chart. Ensure the provided data is a valid time series. {e}","messagePattern":"Failed to convert results to chart\\. Ensure the provided data is a valid time series\\. (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py","lineNumber":66,"sourceCode":"    # pylint: disable=import-outside-toplevel\n    from openbb_charting.core.plotly_ta.ta_class import PlotlyTA\n\n    try:\n        ta = PlotlyTA()\n        fig = ta.plot(  # type: ignore\n            df_stock=data,\n            indicators=indicators,\n            symbol=symbol,\n            candles=candles,\n            volume=volume,\n            prepost=prepost,\n            volume_ticks_x=volume_ticks_x,\n        )\n        content = fig.show(external=True).to_plotly_json()\n\n        return fig, content\n    except Exception as e:\n        raise Exception(\n            f\"Failed to convert results to chart. Ensure the provided data is a valid time series. {e}\"\n        ) from e\n","sourceCodeStart":48,"sourceCodeEnd":69,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/obbject_extensions/charting/openbb_charting/core/to_chart.py#L48-L69","documentation":"to_chart (core/to_chart.py:66) is the bridge that turns router output into a candle/TA chart; its outer `except Exception` re-raises a bare Exception(\"Failed to convert results to chart. Ensure the provided data is a valid time series. {e}\") chaining the original. The inner cause is almost always data-shape related: a DatetimeIndex is missing/unsorted, the frame lacks OHLC columns, or values are non-numeric — i.e. the input is not a valid time series for candlestick plotting.","triggerScenarios":"Passing a DataFrame without a DatetimeIndex (or with unparseable dates), an empty result, non-numeric price columns, or a Pydantic-object list that was never converted to a DataFrame, into obbject.charting.to_chart / the charting extension's .charting() accessor.","commonSituations":"Calling .charting() on a command whose provider returned an empty or malformed frame; forgetting to set df.index = pd.DatetimeIndex(df.date); charting non-time-series data (screening tables, ratings lists).","solutions":["Inspect the chained __cause__ for the precise failure (KeyError, ValueError from plotly, pandas errors).","Normalize before charting: ensure a DatetimeIndex, numeric OHLC columns, and non-empty data (raise/skip when empty).","Confirm the underlying router command actually returned rows — an EmptyDataError upstream sometimes surfaces here as an empty frame.","If the data isn't a time series, render it as a table or bar chart instead of candles."],"exampleFix":"# before\nresult = obbject.equity.price.historical(symbol=\"AAPL\", provider=\"xyz\")\nresult.charting()  # Exception: Failed to convert results to chart...\n\n# after\ndf = result.to_df()\nif not df.empty:\n    df.index = pd.to_datetime(df.index)\n    df[[\"open\", \"high\", \"low\", \"close\"]] = df[[\"open\", \"high\", \"low\", \"close\"]].apply(pd.to_numeric, errors=\"coerce\")\n    obbject.charting.to_chart(data=df, symbol=\"AAPL\", candles=True)","handlingStrategy":"try-catch","validationCode":"def chartable_timeseries(df) -> bool:\n    return (\n        not df.empty\n        and isinstance(df.index, pd.DatetimeIndex)\n        and bool(set(map(str.lower, df.columns)) & {\"close\", \"adj close\", \"adj_close\"})\n    )\n\nif chartable_timeseries(result.to_df()):\n    obbject.charting.to_chart(data=result.to_df(), symbol=\"AAPL\")","typeGuard":"def is_valid_timeseries(df: pd.DataFrame) -> bool:\n    return (not df.empty) and isinstance(df.index, pd.DatetimeIndex) and df.index.is_monotonic_increasing","tryCatchPattern":"try:\n    fig, content = obbject.charting.to_chart(data=df, symbol=symbol)\nexcept Exception as e:\n    logger.error(\"chart conversion failed, cause=%s\", e.__cause__)\n    # fall back to tabular output\n    print(df.to_string())","preventionTips":["Coerce the index with pd.to_datetime and sort before charting.","Ensure numeric dtype on price columns (pd.to_numeric errors='coerce').","Never chart empty frames — check result emptiness first.","Always inspect __cause__; the wrapper message is intentionally generic."],"tags":["python","openbb","charting","time-series","exception-wrapping"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}