microsoft/qlib · error · NotImplementedError
This type of input is not supported
Error message
This type of input is not supported
What it means
Raised by SepDFLocGetter.__getitem__ (the object behind SepDataFrame.loc(axis=1)[...]) when selecting columns and the argument is neither a str nor a tuple/list of keys. SepDataFrame stores separate per-group frames, so fancy indexing (slices, boolean arrays, callables) on axis 1 has no implementation.
Source
Thrown at qlib/contrib/data/utils/sepdf.py:168
def __init__(self, sdf: SepDataFrame, join):
self._sdf = sdf
self.axis = None
self.join = join
def __call__(self, axis):
self.axis = axis
return self
def __getitem__(self, args):
if self.axis == 1:
if isinstance(args, str):
return self._sdf[args]
elif isinstance(args, (tuple, list)):
new_df_dict = {k: self._sdf[k] for k in args}
return SepDataFrame(new_df_dict, join=self.join if self.join in args else args[0], skip_align=True)
else:
raise NotImplementedError(f"This type of input is not supported")
elif self.axis == 0:
return SepDataFrame(
{k: df.loc(axis=0)[args] for k, df in self._sdf._df_dict.items()}, join=self.join, skip_align=True
)
else:
df = self._sdf
if isinstance(args, tuple):
ax0, *ax1 = args
if len(ax1) == 0:
ax1 = None
if ax1 is not None:
df = df.loc(axis=1)[ax1]
if ax0 is not None:
df = df.loc(axis=0)[ax0]
return df
else:
return df.loc(axis=0)[args]
View on GitHub (pinned to 79633dd950)
Solutions
- Use a string or list of column names: sdf.loc(axis=1)['KMID'] or sdf.loc(axis=1)[['KMID', 'KLEN']].
- Convert numpy arrays to lists: sdf.loc(axis=1)[list(col_array)].
- For slice-based selection, first materialize the underlying pandas frame via sdf._df_dict[sdf.join] and use plain pandas .loc.
Example fix
// before sub = sdf.loc(axis=1)[np.array(["KMID", "KLEN"])] # NotImplementedError // after sub = sdf.loc(axis=1)[["KMID", "KLEN"]]
Defensive patterns
Strategy: type-guard
Validate before calling
cols = ["KMID", "KLEN"] assert all(isinstance(c, str) for c in cols) sub = sdf.loc(axis=1)[cols] # list/tuple/str only
Type guard
def valid_axis1_args(args) -> bool:
return isinstance(args, str) or (isinstance(args, (tuple, list)) and all(isinstance(a, str) for a in args)) Try / catch
try:
sub = sdf.loc(axis=1)[args]
except NotImplementedError:
sub = sdf._df_dict[sdf.join].loc(axis=1)[args] # real pandas supports slices/masks Prevention
- Convert numpy arrays of column names to plain lists before indexing.
- Use plain pandas on a materialized frame for slice/boolean column selection.
- Only pass str or tuple/list-of-str to SepDataFrame loc(axis=1).
When it happens
Trigger: Calling sdf.loc(axis=1)[args] where args is a slice (e.g. [:, 'KMID']), a boolean mask, an int, or a numpy array — only a column name or tuple/list of column names are handled at axis 1.
Common situations: Copy-pasting pandas .loc idioms (slices, boolean column masks) onto high-frequency data wrapped in SepDataFrame; passing a numpy array of column names instead of a plain list.
Related errors
- Please implement the `droplevel` method
- nfs-common is not found, please install it by execute: sudo
- Mount failed: requires sudo or permission denied
- mount {provider_uri} on {mount_path} error! Command error
- Mount failed: {e.stderr}
AI-assisted analysis of microsoft/qlib@79633dd950 (2026-08-15).
Data as JSON: /api/errors/089cef04dd3e5131.
Report an issue: GitHub.