21

Just getting this new warning for my dataframes that are loaded from excel.

I understand if I were to pd.DataFrame I could set the index, but I am not clear how to set the dataframe index type when I am loading from a file.

C:\python\python38\lib\site-packages\geopandas\io\file.py:362: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.

Excerpt from class:

xls = pd.ExcelFile('C:/QGISwork/generic_templates/fielddbtemplate_db.xlsx')
        self.header = xls.parse('generic', header = None)
        self.df = xls.parse('generic', skiprows=4, index_col=0, na_values=['NA'])
AAmes
  • 333
  • 1
  • 2
  • 11
  • Does anyone know if there is a way to SPECIFY the index datatype so that I can specifically just choose int() or something like that to avoid this annoying warning? – AAmes Apr 14 '22 at 16:48
  • Maybe have found a solution, will try to post soon. – AAmes Jun 20 '22 at 10:03

5 Answers5

9

I had faced same issue while training XGBoostClassifier on my local machine.

As per this link, I upgraded my XGBoost from 1.5.1 to 1.6.1 and all such warnings disappeared.

To upgrade version you may first need to uninstall current XGBoost package using

pip3 uninstall xgboost

Next, reinstall XGBoost using

pip3 install xgboost

mirekphd
  • 4,799
  • 3
  • 38
  • 59
Mayur Gite
  • 397
  • 4
  • 16
  • 2
    Thanks for your comment, unfortunately I wasn't using xgboost.. so not really the problem case. – AAmes Jun 14 '22 at 14:23
2

The warning is generating merely just by importing xgboost too. No apparent way to stop the warnings unless you explicitly suppress them using the "warnings" library.

Interestingly, the warning only generates when using the specific Int64Index method, but not an equivalent object. I don't think you will have to worry about problems unless you were using this method.

enter image description here

Anthony M
  • 109
  • 8
1

This warning I found coming from xgboost compat.py . I commented out the import parts of multiindex and index64index The warning disappeared
The reason for this could be that the deprecation in pandas new version is not taken into consideration in xgboost even latest versions of it.

M V S RAO
  • 21
  • 1
  • Thanks for your comment, unfortunately I wasn't using xgboost.. so not really the problem case. – AAmes Jun 14 '22 at 14:23
1

I found that the best way to avoid this warning is to import pandas first, then, import MultiIndex and Int16Dtype before importing any other libraries that depend on the Panda index. This is how I got rid of the warning.

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

In my case it was xgboost that needed the Index reference. In your case, it is probably the geopandas library.

0

Just upgrade xgboost

pip install xgboost --upgrade

in jupyter lab:

!pip install xgboost --upgrade

I did this and the problem disappeared

Grzesik
  • 111
  • 2
  • 3