datapane / datapane

Build and share data reports in 100% Python

Home Page:https://datapane.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FutureWarning from pandas to be resolved

Samreay opened this issue · comments

Hi team,

Looks like theres a line in df_processor.py:28 that needs to have its dtype be updated.

.../datapane/common/df_processor.py:28: FutureWarning:

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

I believe the change is a simple:

    # flatten/reset indexes
    if isinstance(df.index, pd.RangeIndex):
        pass  # allow RangeIndex - reset numbers?
    elif isinstance(df.index, pd.Int64Index):
        df.reset_index(inplace=True, drop=True)

to

    from pandas.api.types import is_integer_dtype

   ...

    # flatten/reset indexes
    if isinstance(df.index, pd.RangeIndex):
        pass  # allow RangeIndex - reset numbers?
    elif is_integer_dtype(df.index.dtype):
        df.reset_index(inplace=True, drop=True)

As per the similar fix here in the geopandas library.

Just started using this library and have encountered the above warning. I've tested the patch suggested by @Samreay and it does indeed resolve the pandas warnings.

This issue was closed as "not planned" however will that change?