microsoft/qlib · error · AttributeError
DataHandlerLP has not attribute _data, please set drop_raw =
Error message
DataHandlerLP has not attribute _data, please set drop_raw = False if you want to use raw data
What it means
DataHandlerLP with `drop_raw=True` deletes the original `_data` after processing to save memory. Later access to the raw key (`data_key=DataHandler.DK_R`, e.g. handler.fetch(..., data_key=DK_R) or get_infer_data-adjacent raw reads) raises AttributeError telling you to keep the raw data if you need it.
Source
Thrown at qlib/data/dataset/handler.py:667
# init raw data
super().setup_data(**kwargs)
with TimeInspector.logt("fit & process data"):
if init_type == DataHandlerLP.IT_FIT_IND:
self.fit()
self.process_data()
elif init_type == DataHandlerLP.IT_LS:
self.process_data()
elif init_type == DataHandlerLP.IT_FIT_SEQ:
self.fit_process_data()
else:
raise NotImplementedError(f"This type of input is not supported")
# TODO: Be able to cache handler data. Save the memory for data processing
def _get_df_by_key(self, data_key: DATA_KEY_TYPE = DataHandlerABC.DK_I) -> pd.DataFrame:
if data_key == self.DK_R and self.drop_raw:
raise AttributeError(
"DataHandlerLP has not attribute _data, please set drop_raw = False if you want to use raw data"
)
df = getattr(self, self.ATTR_MAP[data_key])
return df
def fetch(
self,
selector: Union[pd.Timestamp, slice, str] = slice(None, None),
level: Union[str, int] = "datetime",
col_set=DataHandler.CS_ALL,
data_key: DATA_KEY_TYPE = DataHandler.DK_I,
squeeze: bool = False,
proc_func: Callable = None,
) -> pd.DataFrame:
"""
fetch data from underlying data source
ParametersView on GitHub (pinned to 79633dd950)
Solutions
- Set `drop_raw=False` in the handler config.
- Or switch the request to DK_I (infer) / DK_L (learn) if raw is truly unneeded.
Example fix
# before handler = DataHandlerLP(..., drop_raw=True) df = handler.fetch(data_key=DataHandler.DK_R) # after handler = DataHandlerLP(..., drop_raw=False) df = handler.fetch(data_key=DataHandler.DK_R)
Defensive patterns
Strategy: validation
Validate before calling
from qlib.data.dataset.handler import DataHandler
def raw_available(handler) -> bool:
return not getattr(handler, 'drop_raw', False) or hasattr(handler, '_data') Type guard
from qlib.data.dataset.handler import DataHandler
def can_fetch_raw(handler) -> bool:
return not getattr(handler, 'drop_raw', False) Prevention
- Only enable drop_raw when nothing downstream needs DK_R.
- Grep your pipeline for data_key=DK_R before turning on drop_raw.
When it happens
Trigger: Constructing a handler with `drop_raw: true` in config, then calling `handler.fetch(..., data_key=DataHandler.DK_R)` or anything requesting self.DK_R.
Common situations: Memory-tuned production configs that add drop_raw, while downstream code (e.g. some benchmarks or custom processors) still asks for raw data; also forgetting drop_raw was set in a base config.
Related errors
- This type of input is not supported
- method {method} is not supported!
- This type of input {rtype} is not supported
- Can't find the BASE_CONFIG file: {base_config_path}
- Invalid Qlib configuration (note: the global config has alre
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/3230e1f138d2f55b.
Report an issue: GitHub.