{"record":{"id":"c31452d3763fe933","repo":"microsoft/qlib","slug":"ts-feature-should-be-pd-dataframe-series-not-typ","errorCode":null,"errorMessage":"ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}","messagePattern":"ts_feature should be pd\\.DataFrame/Series, not (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"qlib/utils/resam.py","lineNumber":235,"sourceCode":"        - if last is True, get the last valid value\n        - else, get the first valid value\n\n    Returns\n    -------\n    Nan | float\n        the first/last valid value\n    \"\"\"\n    return series.ffill().iloc[-1] if last else series.bfill().iloc[0]\n\n\ndef _ts_data_valid(ts_feature, last=False):\n    \"\"\"get the first/last not nan value of pd.Series|DataFrame with single level index\"\"\"\n    if isinstance(ts_feature, pd.DataFrame):\n        return ts_feature.apply(lambda column: get_valid_value(column, last=last))\n    elif isinstance(ts_feature, pd.Series):\n        return get_valid_value(ts_feature, last=last)\n    else:\n        raise TypeError(f\"ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}\")\n\n\nts_data_last = partial(_ts_data_valid, last=True)\nts_data_first = partial(_ts_data_valid, last=False)\n","sourceCodeStart":217,"sourceCodeEnd":240,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/utils/resam.py#L217-L240","documentation":"Error \"ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}\" thrown in microsoft/qlib.","triggerScenarios":"This error is raised at qlib/utils/resam.py:235 when the guard condition fails: \"ts_feature should be pd.DataFrame/Series\". It triggers when the code path receives input or a state that violates the precondition checked at this point — e.g. an unimplemented abstract method being called, an unsupported argument type/value, or an invalid configuration. To avoid it, satisfy the documented precondition before this call: implement the required method in your subclass, or pass a supported value of the expected type as described by the message.","commonSituations":"See trigger scenarios.","solutions":["Pass ts_feature as a pd.DataFrame or pd.Series.","Convert your input with pd.DataFrame(...) or pd.Series(...) before calling the resample function."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}