microsoft/qlib · error · NotImplementedError

Please implement the `to_series` method

Error message

Please implement the `to_series` method

What it means

Error "Please implement the `to_series` method" thrown in microsoft/qlib.

Source

Thrown at qlib/backtest/high_performance_ds.py:433

            fill np.nan with value. By default None.
        """

        raise NotImplementedError(f"Please implement the 'sum_all_indicators' method")

    def to_series(self) -> Dict[Text, pd.Series]:
        """return the metrics as pandas series

        for example: { "ffr":
                SH600068    NaN
                SH600079    1.0
                SH600266    NaN
                           ...
                SZ300692    NaN
                SZ300719    NaN,
                ...
         }
        """
        raise NotImplementedError(f"Please implement the `to_series` method")


class SingleMetric(BaseSingleMetric):
    def __init__(self, metric):
        self.metric = metric

    def __add__(self, other):
        if isinstance(other, (int, float)):
            return self.__class__(self.metric + other)
        elif isinstance(other, self.__class__):
            return self.__class__(self.metric + other.metric)
        else:
            return NotImplemented

    def __sub__(self, other):
        if isinstance(other, (int, float)):
            return self.__class__(self.metric - other)
        elif isinstance(other, self.__class__):

View on GitHub (pinned to 79633dd950)

Solutions

  1. Implement the `to_series` method in your subclass before calling it.
  2. Use a concrete class that provides `to_series` instead of the abstract base.

When it happens

Trigger: This error is raised at qlib/backtest/high_performance_ds.py:433 when the guard condition fails: "Please implement the `to_series` method". 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/066db4d8bbedd353. Report an issue: GitHub.