From ed33d8cc9f3ef76d8476e12176570f66135a6ff5 Mon Sep 17 00:00:00 2001 From: whning Date: Fri, 5 Jun 2026 01:59:52 +0800 Subject: [PATCH] Fix DataFrame.applymap deprecation in CSIIndex._parse_excel Replace with . DataFrame.applymap() was removed in pandas 2.2.0 (replaced by DataFrame.map() since pandas 1.4.0). This call in CSIIndex._parse_excel at line 174 would raise AttributeError on pandas >= 2.2.0 when processing index constituent changes from Excel files. Note: _parse_table at line 197 and get_new_companies at line 321 already use .map(), so this brings _parse_excel in line with the rest of the collector. --- scripts/data_collector/cn_index/collector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/data_collector/cn_index/collector.py b/scripts/data_collector/cn_index/collector.py index 51ba0b95cc9..06368b183c5 100644 --- a/scripts/data_collector/cn_index/collector.py +++ b/scripts/data_collector/cn_index/collector.py @@ -171,7 +171,7 @@ def _parse_excel(self, excel_url: str, add_date: pd.Timestamp, remove_date: pd.T for _s_name, _type, _date in [("调入", self.ADD, add_date), ("调出", self.REMOVE, remove_date)]: _df = df_map[_s_name] _df = _df.loc[_df["指数代码"] == self.index_code, ["证券代码"]] - _df = _df.applymap(self.normalize_symbol) + _df = _df.map(self.normalize_symbol) _df.columns = [self.SYMBOL_FIELD_NAME] _df["type"] = _type _df[self.DATE_FIELD_NAME] = _date