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

Posted 叶庭云

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了FutureWarning: pandas.Int64Index is deprecated and will be removed ... in a future version. 解决方法相关的知识,希望对你有一定的参考价值。


调用 XGBoost 时遇到如下 FutureWarning:

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)):

我的解决方法:

pip uninstall pandas
pip install pandas==1.3

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

import pandas as pd 
from pandas import MultiIndex, Int16Dtype
import xgboost as xgb

以上是关于FutureWarning: pandas.Int64Index is deprecated and will be removed ... in a future version. 解决方法的主要内容,如果未能解决你的问题,请参考以下文章

FutureWarning 未与 warnings.simplefilter(action = "error", category=FutureWarning) 一起显示

numpy:FutureWarning:元素比较失败

FutureWarning

TensorFlow忽略警告信息:FutureWarning

为啥我得到这个错误结果=方法(y)FutureWarning:元素比较失败;而是返回标量

Python loc + isin 返回 FutureWarning(元素比较失败)