{"record":{"id":"dabb80b8b7a8936a","repo":"OpenBB-finance/OpenBB","slug":"no-data-is-left-after-dropping-nan-values-try-set","errorCode":null,"errorMessage":"No data is left after dropping NaN values. Try setting `dropnan = False`, or use the `frequency` parameter on request.","messagePattern":"No data is left after dropping NaN values\\. Try setting `dropnan = False`, or use the `frequency` parameter on request\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/economy/openbb_economy/economy_views.py","lineNumber":82,"sourceCode":"\n        else:\n            df_ta = basemodel_to_df(kwargs[\"obbject_item\"], index=\"date\")  # type: ignore\n\n        # Check for unsupported external data injection.\n        if allow_unsafe is False and data_cols:\n            for data_col in data_cols:\n                if data_col not in columns:\n                    raise RuntimeError(\n                        f\"Column '{data_col}' was not found in the original data.\"\n                        + \" External data injection is not supported unless `allow_unsafe = True`.\"\n                    )\n\n        # Align the data so each column has the same index and length.\n        if dropnan:\n            df_ta = df_ta.dropna(how=\"any\")\n\n        if df_ta.empty or len(df_ta) < 2:\n            raise ValueError(\n                \"No data is left after dropping NaN values. Try setting `dropnan = False`,\"\n                + \" or use the `frequency` parameter on request.\"\n            )\n\n        columns = df_ta.columns.to_list()\n\n        metadata = kwargs[\"extra\"].get(\"results_metadata\", {})  # type: ignore\n\n        # Check if the request was transformed by the FRED API.\n        params = kwargs[\"extra_params\"] if kwargs.get(\"extra_params\") else {}\n        has_params = hasattr(params, \"transform\") and params.transform is not None  # type: ignore\n\n        # Get a unique list of all units of measurement in the DataFrame.\n        y_units = list({metadata.get(col).get(\"units\") for col in columns if col in metadata})  # type: ignore\n        if has_params is True and not y_units:\n            y_units = [ytitle_dict.get(params.transform)]  # type: ignore\n\n        if normalize or (","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/economy/openbb_economy/economy_views.py#L64-L100","documentation":"After aligning the data, the FRED charting view drops NaN rows when dropna=True (the default); if the remaining frame is empty or has fewer than 2 rows, nothing can be plotted and this ValueError is raised. The message points at the two levers: disabling dropna or requesting a transformed/aligned frequency so the series overlap.","triggerScenarios":"Plotting multiple FRED series with mismatched publication dates (annual vs daily) where dropna(how='any') removes every row; a single series that is all-NaN after alignment; charting with dropnan=True on sparse quarterly data.","commonSituations":"Comparing series with different frequencies (GDP quarterly vs CPI monthly), series with leading NaNs from different start dates, or providers returning nulls for recent periods.","solutions":["Set dropnan=False in the charting kwargs so rows with partial NaNs are kept.","Request data with a matching frequency/transform on the FRED request (e.g. transform='pch', annual aggregation) so indexes align.","Pre-align your injected data with join/how='inner' or forward-fill before passing it in.","Verify each series is non-empty: check res.to_df().dropna(how='all') before charting."],"exampleFix":"# before\nfig = obb.economy.fred.series(['GDP','DGS10'], provider='fred').charting.fred()  # misaligned dates -> all NaN\n\n# after\nfig = obb.economy.fred.series(['GDP','DGS10'], provider='fred').charting.fred(dropnan=False)\n# or align via transform:\nfig = obb.economy.fred.series(['GDP','DGS10'], provider='fred', transform='a').charting.fred()","handlingStrategy":"validation","validationCode":"df = res.to_df()\naligned = df.dropna(how='any') if dropnan else df\nif len(aligned) < 2:\n    # fall back: keep partial rows\n    aligned = df.dropna(how='all')\nassert len(aligned) >= 2, 'no overlapping dates across series'","typeGuard":"def has_overlapping_rows(df, min_rows: int = 2) -> bool:\n    \"\"\"True when at least `min_rows` survive an inner alignment.\"\"\"\n    return len(df.dropna(how='any')) >= min_rows","tryCatchPattern":"try:\n    fig = res.charting.fred()\nexcept ValueError as e:\n    if 'No data is left after dropping NaN' in str(e):\n        fig = res.charting.fred(dropnan=False)\n    else:\n        raise","preventionTips":["Check date-index overlap (res.to_df().dropna(how='any').shape) before charting multi-series.","Prefer requesting a shared frequency/transform upstream.","Default to dropnan=False when mixing publication cadences."],"tags":["charting","fred","nan-handling","data-alignment"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}