FutureWarning: pandas.Int64Index is deprecated and will be removed ... in a future version. 解决方法

2022-10-25 18:30:38 浏览数 (1)


调用 XGBoost 时遇到如下 FutureWarning:

代码语言:javascript复制
compat.py:36: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
  from pandas import MultiIndex, Int64Index


data.py:267: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
  elif isinstance(data.columns, (pd.Int64Index, pd.RangeIndex)):

我的解决方法:

代码语言:javascript复制
pip uninstall pandas
pip install pandas==1.3

其他解决方案说降低 xgboost 的版本,或者先导入 MultiIndex, Int16Dtype,如下所示:

代码语言:javascript复制
import pandas as pd 
from pandas import MultiIndex, Int16Dtype
import xgboost as xgb

  • stackoverflow | pandas.Int64Index fix for FutureWarning
  • 编程技术网 | Pandas.Int64Index被弃用:pandas.Int64Index is deprecated

0 人点赞