{"record":{"id":"196c82838591d132","repo":"microsoft/qlib","slug":"this-type-of-input-is-not-supported-196c82","errorCode":null,"errorMessage":"This type of input is not supported","messagePattern":"This type of input is not supported","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"qlib/data/dataset/__init__.py","lineNumber":594,"sourceCode":"        Tuple[int]:\n            the row and col index\n        \"\"\"\n        # The the right row number `i` and col number `j` in idx_df\n        if isinstance(idx, (int, np.integer)):\n            real_idx = idx\n            if 0 <= real_idx < len(self.idx_map):\n                i, j = self.idx_map[real_idx]  # TODO: The performance of this line is not good\n            else:\n                raise KeyError(f\"{real_idx} is out of [0, {len(self.idx_map)})\")\n        elif isinstance(idx, tuple):\n            # <TSDataSampler object>[\"datetime\", \"instruments\"]\n            date, inst = idx\n            date = pd.Timestamp(date)\n            i = bisect.bisect_right(self.idx_df.index, date) - 1\n            # NOTE: This relies on the idx_df columns sorted in `__init__`\n            j = bisect.bisect_left(self.idx_df.columns, inst)\n        else:\n            raise NotImplementedError(f\"This type of input is not supported\")\n        return i, j\n\n    def __getitem__(self, idx: Union[int, Tuple[object, str], List[int]]):\n        \"\"\"\n        # We have two method to get the time-series of a sample\n        tsds is a instance of TSDataSampler\n\n        # 1) sample by int index directly\n        tsds[len(tsds) - 1]\n\n        # 2) sample by <datetime,instrument> index\n        tsds['2016-12-31', \"SZ300315\"]\n\n        # The return value will be similar to the data retrieved by following code\n        df.loc(axis=0)['2015-01-01':'2016-12-31', \"SZ300315\"].iloc[-30:]\n\n        Parameters\n        ----------","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/microsoft/qlib/blob/79633dd9506ea689e5400dea0197717b5b3d74b7/qlib/data/dataset/__init__.py#L576-L612","documentation":"TSDataSampler.__get_idx accepts exactly two index shapes: an int (flat sample number) or a (date, instrument) tuple for coordinate lookup. Anything else — a string alone, a list of strings, None — raises NotImplementedError.","triggerScenarios":"Calling `tsds['SH600000']` (instrument alone) or `tsds[['2020-01-01','SH600000']]` (list instead of tuple), or `tsds['2020-01-01', 'SH600000', 'extra']`.","commonSituations":"Code migrating from pandas DataFrame indexing where single-key access works; json-decoded keys that arrive as lists rather than tuples.","solutions":["Use a tuple: `tsds['2016-12-31', 'SZ300315']`.","Or use an integer index: `tsds[len(tsds) - 1]`.","Convert lists to tuples: `tsds[tuple(key)]`."],"exampleFix":"# before\nsample = tsds['SH600000']\n\n# after\nsample = tsds['2020-01-01', 'SH600000']  # (date, instrument) tuple","handlingStrategy":"type-guard","validationCode":"def valid_tsds_key(idx) -> bool:\n    return isinstance(idx, int) or (isinstance(idx, tuple) and len(idx) == 2)","typeGuard":"from typing import Union, Tuple, object as _o\n\ndef is_tsds_key(idx) -> bool:\n    return isinstance(idx, int) or (isinstance(idx, tuple) and len(idx) == 2)","tryCatchPattern":null,"preventionTips":["Remember TSDataSampler is not a DataFrame: only int or (date, inst) tuple.","Coerce JSON/config keys (often lists) to tuples before indexing."],"tags":["dataset","indexing","type-error"],"backgroundTag":null,"analyzedSha":"79633dd9506ea689e5400dea0197717b5b3d74b7","analyzedAt":"2026-08-15T07:01:27.511Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}