Skip to content

COMPAT: IntegerXXDtypes string repr cause numpy deprecation warnings #24593

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

The 'numeric-style' type codes are deprecated in numpy, but they clash with our pandas integer dtypes strings (with the capital):

In [7]: np.dtype('Int64')                                     
/home/joris/miniconda3/envs/dev/bin/ipython:1: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
  #!/home/joris/miniconda3/envs/dev/bin/python
Out[7]: dtype('int64')

This causes some deprecation warnings in pd.core.dtypes.common._get_dtype_type, which surfaces those through eg is_integer_dtype:

In [1]: import warnings                                      

In [2]: warnings.simplefilter('always', DeprecationWarning)

In [3]: pd.api.types.pandas_dtype('Int64')                                                
Out[3]: <pandas.core.arrays.integer.Int64Dtype at 0x7fa8dc28c518>

In [4]: pd.core.dtypes.common._get_dtype_type('Int64')                                             
/home/joris/scipy/pandas/pandas/core/dtypes/common.py:1864: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
  return _get_dtype_type(np.dtype(arr_or_dtype))
Out[4]: numpy.int64

In [6]: pd.api.types.is_integer_dtype('Int64')                         
/home/joris/scipy/pandas/pandas/core/dtypes/common.py:1864: DeprecationWarning: Numeric-style type codes are deprecated and will result in an error in the future.
  return _get_dtype_type(np.dtype(arr_or_dtype))
Out[6]: True

Metadata

Metadata

Assignees

No one assigned

    Labels

    Dtype ConversionsUnexpected or buggy dtype conversionsExtensionArrayExtending pandas with custom dtypes or arrays.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions