{"record":{"id":"60b1639203b1d0e5","repo":"OpenBB-finance/OpenBB","slug":"error-expected-data-with-numeric-values","errorCode":null,"errorMessage":"Error: expected data with numeric values.","messagePattern":"Error: expected data with numeric values\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/obbject_extensions/charting/openbb_charting/charts/generic_charts.py","lineNumber":150,"sourceCode":"    y2 = y2 if y2 else []\n    yaxis_num = 1\n    yaxis = f\"y{yaxis_num}\"\n    first_y = y[0]  # type: ignore[index]\n    second_y = None\n    third_y = None\n    add_scatter = False\n\n    # Attempt to layout the chart automatically with multiple y-axis.\n    mode = scatter_kwargs.pop(\"mode\", \"lines\")\n    hovertemplate = scatter_kwargs.pop(\"hovertemplate\", None)\n\n    if auto_layout is True:\n        # Sort columns by the difference between the max and min values.\n        # This is to help determine which columns should share the same y-axis.\n        diff = df.max(numeric_only=True) - df.min(numeric_only=True)\n        sorted_columns = diff.sort_values(ascending=False).index\n        if sorted_columns is None or len(sorted_columns) == 0:\n            raise ValueError(\"Error: expected data with numeric values.\")\n        df = df[sorted_columns]  # type: ignore\n\n        for i, col in enumerate(df.columns):\n            if col in y:  # type: ignore[operator]\n                hovertemplate = (\n                    hovertemplate\n                    if hovertemplate\n                    else f\"{df[col].name}: %{{y}}<extra></extra>\"\n                )\n                share_yaxis = should_share_axis(df, first_y, col, threshold=2.5)\n                if share_yaxis is True:\n                    add_scatter = True\n                if share_yaxis is False:\n                    yaxis_num = 2\n                    yaxis = f\"y{yaxis_num}\"\n                    if second_y is None:\n                        second_y = col\n                        add_scatter = True","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/obbject_extensions/charting/openbb_charting/charts/generic_charts.py#L132-L168","documentation":"In create_line_chart's auto_layout branch, columns are ordered by their max-min spread computed with numeric_only=True. If no column is numeric, the sorted index is empty and the ValueError 'expected data with numeric values' is raised - the multi-axis layout algorithm needs at least one numeric series to assign to y-axes.","triggerScenarios":"Calling create_line_chart(..., auto_layout=True) with a DataFrame whose columns are all strings/dates/objects; mixed frames where numeric columns are stored as object dtype (e.g. strings '1.2'); auto-layout reached through .charting() on results with only categorical fields.","commonSituations":"Provider data read from CSV with numbers as strings; date-only DataFrames; columns containing None-heavy object arrays that numeric_only drops entirely.","solutions":["Coerce columns to numeric: df = df.apply(pd.to_numeric, errors='coerce')","Pass only the numeric columns: create_line_chart(data=df[['price','volume']])","Disable auto_layout and specify x/y explicitly"],"exampleFix":"# before\nfig = create_line_chart(data=df, auto_layout=True)  # all-object dtypes\n\n# after\ndf = df.apply(pd.to_numeric, errors='coerce').dropna(axis=1, how='all')\nfig = create_line_chart(data=df, auto_layout=True)","handlingStrategy":"validation","validationCode":"num = df.select_dtypes('number')\nassert not num.empty, 'line chart auto_layout needs numeric columns'\ndf = df[num.columns.union(df.columns[:1])]","typeGuard":"def has_numeric_columns(df: pd.DataFrame) -> bool:\n    return not df.select_dtypes('number').empty","tryCatchPattern":"try:\n    fig = create_line_chart(data=df, auto_layout=True)\nexcept ValueError as e:\n    if 'numeric values' in str(e):\n        fig = create_line_chart(data=df.apply(pd.to_numeric, errors='coerce').dropna(axis=1, how='all'), auto_layout=True)","preventionTips":["Coerce dtypes with pd.to_numeric at ingest time","Validate select_dtypes('number') is non-empty before auto_layout","Avoid object-dtype columns from CSV imports"],"tags":["openbb","charting","dtype","numeric-required"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}