microsoft/qlib · error · TypeError
ts_feature should be pd.DataFrame/Series, not {type(ts_featu
Error message
ts_feature should be pd.DataFrame/Series, not {type(ts_feature)} What it means
Error "ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}" thrown in microsoft/qlib.
Source
Thrown at qlib/utils/resam.py:235
- if last is True, get the last valid value
- else, get the first valid value
Returns
-------
Nan | float
the first/last valid value
"""
return series.ffill().iloc[-1] if last else series.bfill().iloc[0]
def _ts_data_valid(ts_feature, last=False):
"""get the first/last not nan value of pd.Series|DataFrame with single level index"""
if isinstance(ts_feature, pd.DataFrame):
return ts_feature.apply(lambda column: get_valid_value(column, last=last))
elif isinstance(ts_feature, pd.Series):
return get_valid_value(ts_feature, last=last)
else:
raise TypeError(f"ts_feature should be pd.DataFrame/Series, not {type(ts_feature)}")
ts_data_last = partial(_ts_data_valid, last=True)
ts_data_first = partial(_ts_data_valid, last=False)
View on GitHub (pinned to 79633dd950)
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.
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/c31452d3763fe933.
Report an issue: GitHub.