{"record":{"id":"f892da9d74e95706","repo":"OpenBB-finance/OpenBB","slug":"data-must-be-a-list-of-data-objects-or-a-dataframe","errorCode":null,"errorMessage":"Data must be a list of Data objects or a DataFrame with a 'date' column.","messagePattern":"Data must be a list of Data objects or a DataFrame with a 'date' column\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/technical/openbb_technical/relative_rotation.py","lineNumber":287,"sourceCode":"        target_col = \"volume\" if study == \"volume\" else \"close\"\n\n        if isinstance(data, OBBject):\n            data = data.results  # type: ignore\n\n        if isinstance(data, list) and (\n            all(isinstance(d, Data) for d in data)\n            or all(isinstance(d, dict) for d in data)\n        ):\n            with contextlib.suppress(Exception):\n                df = basemodel_to_df(convert_to_basemodel(data), index=\"date\")\n\n        if isinstance(data, DataFrame) and not df.empty:\n            df = data.copy()\n            if \"date\" in df.columns:\n                df.set_index(\"date\", inplace=True)\n\n        if df.empty:\n            raise ValueError(\n                \"Data must be a list of Data objects or a DataFrame with a 'date' column.\"\n            )\n\n        if \"symbol\" in df.columns:\n            df = df.pivot(columns=\"symbol\", values=target_col)\n\n        if benchmark not in df.columns:\n            raise RuntimeError(\"The benchmark symbol was not found in the data.\")\n\n        benchmark_data = df.pop(benchmark).to_frame()\n        symbols_data = df\n\n        if len(symbols_data) <= 252 and study in [\"price\", \"volume\"]:  # type: ignore\n            raise ValueError(\n                \"Supplied data must be daily intervals and have more than one year of back data to calculate\"\n                \" the most recent day in the time series.\"\n            )\n","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/technical/openbb_technical/relative_rotation.py#L269-L305","documentation":"Raised in RelativeRotation (__init__) when the supplied data could not be converted into a usable DataFrame: it accepts an OBBject, a list of Data models/dicts, or a DataFrame, and after conversion attempts df is still empty. This usually means the input shape was not one of the supported forms (or conversion silently failed via contextlib.suppress).","triggerScenarios":"Calling RelativeRotation with an empty list, a list of non-Data/non-dict items, a DataFrame lacking a 'date' column and with empty content, or a dict that basemodel_to_df cannot index by 'date'.","commonSituations":"Passing provider results whose 'date' field is named differently ('Date', 'timestamp'); passing raw JSON arrays of strings; empty responses from an upstream fetch (no data returned for the symbols); passing OBBject whose .results is empty.","solutions":["Pass the OBBject directly (RelativeRotation accepts it) rather than manually extracting pieces.","Ensure the list items are Data model instances or dicts containing a 'date' field (lowercase).","If passing a DataFrame, include a 'date' column and 'symbol' column.","Check that the upstream historical fetch actually returned rows before constructing the RRG."],"exampleFix":"# before\nrrg = RelativeRotation(data=res.to_df().drop(columns=[\"date\"]), benchmark=\"SPY\")  # date dropped\n\n# after\nrrg = RelativeRotation(data=res, benchmark=\"SPY\")  # pass OBBject with date intact","handlingStrategy":"validation","validationCode":"assert df is not None and not df.empty and \"date\" in getattr(df, \"columns\", []), \"RRG needs non-empty data with a date field\"","typeGuard":"def rrg_input_valid(data) -> bool:\n    if hasattr(data, \"results\"):\n        data = data.results\n    return bool(data) and not getattr(data, \"empty\", False)","tryCatchPattern":"try:\n    rrg = RelativeRotation(data=data, benchmark=\"SPY\")\nexcept ValueError as e:\n    if \"list of Data objects\" in str(e):\n        df = normalize_to_df_with_date(data)  # ensure 'date' column, then retry\n        rrg = RelativeRotation(data=df, benchmark=\"SPY\")\n    else:\n        raise","preventionTips":["Pass the OBBject straight from the fetch call","Guarantee a lowercase 'date' field in list inputs","Check fetch results are non-empty before RRG construction"],"tags":["rrg","relative-rotation","data-shape","validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}