microsoft/qlib · error · ValueError
{str(e)}. \n\t{warning_info}
Error message
{str(e)}. \n\t{warning_info} What it means
Raised by NpPairOperator._load_internal (qlib/data/ops.py) when numpy rejects the element-wise operation between the left and right feature series (e.g. np.divmod, np.arctan2 on incompatible data). The original numpy ValueError is caught, a detailed warning_info string (operator, both feature expressions, instrument, and length mismatch note) is logged at debug level, and a new ValueError chaining the original is re-raised. It almost always means the two operand features produced series that cannot be paired — most commonly different lengths.
Source
Thrown at qlib/data/ops.py:331
check_length = isinstance(series_left, (np.ndarray, pd.Series)) and isinstance(
series_right, (np.ndarray, pd.Series)
)
if check_length:
warning_info = (
f"Loading {instrument}: {str(self)}; np.{self.func}(series_left, series_right), "
f"The length of series_left and series_right is different: ({len(series_left)}, {len(series_right)}), "
f"series_left is {str(self.feature_left)}, series_right is {str(self.feature_right)}. Please check the data"
)
else:
warning_info = (
f"Loading {instrument}: {str(self)}; np.{self.func}(series_left, series_right), "
f"series_left is {str(self.feature_left)}, series_right is {str(self.feature_right)}. Please check the data"
)
try:
res = getattr(np, self.func)(series_left, series_right)
except ValueError as e:
get_module_logger("ops").debug(warning_info)
raise ValueError(f"{str(e)}. \n\t{warning_info}") from e
else:
if check_length and len(series_left) != len(series_right):
get_module_logger("ops").debug(warning_info)
return res
class Power(NpPairOperator):
"""Power Operator
Parameters
----------
feature_left : Expression
feature instance
feature_right : Expression
feature instance
Returns
----------View on GitHub (pinned to 79633dd950)
Solutions
- Re-dump or repair the qlib bin data so both operand features have data for the requested instrument and range (qlib's dump_bin.py).
- Simplify the expression: load each operand separately for the failing instrument (enable the ops debug logger: logging.getLogger('ops').setLevel(logging.DEBUG)) to see which side is empty.
- Wrap operands or the whole pair operator in operators that tolerate NaN (e.g. If/IsNa) or use qlib's Fillna processor afterwards instead of relying on broken inputs.
- If series lengths differ due to a custom data handler, fix the handler so both features are aligned on the same datetime index.
Example fix
# before (expression that can fail when one side has no data)
fields = ["Div($close, $volume)"]
# after (guard against missing operand data; fill after computing)
fields = ["If(IsNa($volume), NaN, Div($close, $volume))"]
# and/or in the processor list:
# {"class": "Fillna", "kwargs": {"fields_group": "feature"}} Defensive patterns
Strategy: try-catch
Try / catch
import logging
logging.getLogger("ops").setLevel(logging.DEBUG)
try:
df = D.features(insts, [expr], start, end)
except ValueError as e:
if "Please check the data" in str(e):
logger.error("feature data incomplete for %s; re-dump bins", expr)
raise Prevention
- Validate data completeness per instrument/field after every dump (count non-NaN rows).
- Wrap risky pair operations in If/IsNa guards and add a Fillna processor.
- Keep the ops logger at DEBUG during development to get the diagnostic context.
When it happens
Trigger: Using binary element-wise expression operators such as Div(feature_left, feature_right), Sub(...), Gt(...) where one operand is NaN-only, empty, or the two series have different lengths (check_length=True path warns; the np call itself can still fail on shape mismatch). Typical with mismatched data availability between two features for one instrument.
Common situations: Expressions mixing features with different calendars or missing data coverage (e.g. a feature only defined for part of the instruments); data holes in a local bin store for one operand; stale or partially dumped qlib data where one field exists and another does not.
Related errors
- {lack_stock} doesn't have close price in qlib in the latest
- Most of samples are dropped. Please check this task: {task}
- Empty data from dataset, please check your dataset config.
- Empty data from dataset, please check your dataset config.
- The rolling window size of Skewness operation should >= 3
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/3ff4a6c3d23ea74e.
Report an issue: GitHub.