FutureWarning: pandas.Int64Index is deprecated

I updated to PyGMT 0.6 today, and using Python 3.9.10 (see complete list below). I’m getting a lot of these warnings with several pygmt commands …

FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.

Anybody else experiencing this?

Thanks, Trevor.

Complete list of dependency information:
numpy: 1.22.3
pandas: 1.4.1
xarray: 2022.3.0
netCDF4: 1.5.8
packaging: 21.3
ghostscript: 9.54.0
gmt: 6.3.0

I have not encountered this warning. I suspect that pandas was also updated in your environment when updating PyGMT. This warning was introduced by pandas in 1.4.0 (see https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Int64Index.html?highlight=int64index).

I was hoping this would be fixed in v0.7 … alas not. This is still the warning:

FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.

FYI, pygmt.show_versions() gives …

PyGMT information:
version: v0.7.0
System information:
python: 3.10.5 | packaged by conda-forge | (main, Jun 14 2022, 06:57:19) [MSC v.1929 64 bit (AMD64)]
executable: C:\Users\ … \python.exe
machine: Windows-10-10.0.19044-SP0
Dependency information:
numpy: 1.22.4
pandas: 1.4.2
xarray: 2022.3.0
netCDF4: 1.6.0
packaging: 21.3
geopandas: 0.10.2
ghostscript: 9.54.0
gmt: 6.4.0
GMT library information:
binary dir: C:/Users/ … /Anaconda3/envs/ …
cores: 12
grid layout: rows
library path: C:/Users/ … /Library/bin/gmt.dll
padding: 2
plugin dir: C:/Users/ … /Library/bin/gmt_plugins
share dir: C:/Users/ … /Library/share/gmt
version: 6.4.0

Are you getting these warnings using pandas objects that were created by PyGMT or separately? If they were created by PyGMT, what function did you use to create them?

The warning is raised by geopandas, not PyGMT. So there is nothing we can do on the PyGMT side. But it’s possible to suppress the warning following the instructions in

2 Likes

Created a geodataframe from a saved shapefile:
gdf_poly = gpd.read_file(filename='shapefile_poly')

Then plotted with PyGMT:
fig.plot(data=gdf_poly)