Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
In [1]: import pandas as pd
In [2]: pd.__version__
Out[2]: '2.1.0.dev0+5.g8d2a4e11d1'
In [3]: import numpy as np
In [4]: np.__version__
Out[4]: '1.23.5'
In [5]: s = pd.Series([1,2,3])
In [6]: s.astype(np.integer)
Out[6]:
0 1
1 2
2 3
dtype: int32
In [7]: np.dtype(np.integer)
<ipython-input-7-c11ccc0059df>:1: DeprecationWarning: Converting `np.integer` or `np.signedinteger` to a dtype is deprecated. The current result is `np.dtype(np.int_)` which is not strictly correct. Note that the result depends on the system. To ensure stable results use may want to use `np.int64` or `np.int32`.
np.dtype(np.integer)
Out[7]: dtype('int32')
In [8]: from pandas.core.dtypes.common import pandas_dtype
In [9]: pandas_dtype(np.integer)
Out[9]: dtype('int32')
Issue Description
For some reason, if you call Series.astype(np.integer)
, the warning from numpy
about calling np.dtype(np.integer)
is suppressed.
This came up in some pandas-stubs testing. pandas.core.dtypes.common.pandas_dtype()
calles np.dtype()
, but we don't print the deprecation warning.
The way we saw it is that it got printed by pytest
Expected Behavior
We should print the numpy deprecation warning.
Installed Versions
Comment From: dannyi96
take
Comment From: luke396
Furthermore, many warning.filterwarnings
have been added to suppress DeprecationWarning
from numpy
. Would it be a better option to simply ignore this warning?