diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index e09c55130..0fb8eed2a 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -286,8 +286,6 @@ IndexIterScalar: TypeAlias = ( | float | Timestamp | Timedelta - | np.integer - | np.float_ ) Scalar: TypeAlias = IndexIterScalar | complex ScalarT = TypeVar("ScalarT", bound=Scalar) diff --git a/pandas-stubs/core/series.pyi b/pandas-stubs/core/series.pyi index 062dbe0fc..227458764 100644 --- a/pandas-stubs/core/series.pyi +++ b/pandas-stubs/core/series.pyi @@ -1609,7 +1609,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]): level: None = ..., numeric_only: _bool = ..., **kwargs, - ) -> np.float64: ... + ) -> float: ... def median( self, axis: AxisIndex | None = ..., diff --git a/tests/test_frame.py b/tests/test_frame.py index 60b5efd51..893eb46f0 100644 --- a/tests/test_frame.py +++ b/tests/test_frame.py @@ -2019,12 +2019,12 @@ def test_groupby_apply() -> None: # GH 167 df = pd.DataFrame({"col1": [1, 2, 3], "col2": [4, 5, 6]}) - def sum_mean(x: pd.DataFrame) -> np.float64: + def sum_mean(x: pd.DataFrame) -> float: return x.sum().mean() check(assert_type(df.groupby("col1").apply(sum_mean), pd.Series), pd.Series) - lfunc: Callable[[pd.DataFrame], np.float64] = lambda x: x.sum().mean() + lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean() check( assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series, diff --git a/tests/test_resampler.py b/tests/test_resampler.py index ba27dfd18..313599a01 100644 --- a/tests/test_resampler.py +++ b/tests/test_resampler.py @@ -155,7 +155,7 @@ def g(val: DataFrame) -> Series: check(assert_type(DF.resample("m").pipe(g), DataFrame), DataFrame) - def h(val: DataFrame) -> np.float64: + def h(val: DataFrame) -> float: return val.mean().mean() check(assert_type(DF.resample("m").pipe(h), Series), Series) @@ -245,10 +245,10 @@ def test_aggregate_series() -> None: DataFrame, ) - def f(val: Series) -> np.float64: + def f(val: Series) -> float: return val.mean() - check(assert_type(S.resample("m").aggregate(f), _AggRetType), pd.Series) + check(assert_type(S.resample("m").aggregate(f), _AggRetType), Series) def test_asfreq_series() -> None: diff --git a/tests/test_series.py b/tests/test_series.py index b57de1fe8..8435c134b 100644 --- a/tests/test_series.py +++ b/tests/test_series.py @@ -306,10 +306,10 @@ def test_types_rank() -> None: def test_types_mean() -> None: s = pd.Series([1, 2, 3, np.nan]) - check(assert_type(s.mean(), np.float64), np.float64) + f1: float = s.mean() s1: pd.Series = s.groupby(level=0).mean() - f2: np.float64 = s.mean(skipna=False) - f3: np.float64 = s.mean(numeric_only=False) + f2: float = s.mean(skipna=False) + f3: float = s.mean(numeric_only=False) def test_types_median() -> None: diff --git a/tests/test_windowing.py b/tests/test_windowing.py index 28fdf62ee..bf0d88dbf 100644 --- a/tests/test_windowing.py +++ b/tests/test_windowing.py @@ -148,7 +148,7 @@ def test_rolling_basic_math_series() -> None: def test_rolling_apply_series() -> None: check(assert_type(S.rolling(10).apply(np.mean), Series), Series) - def _mean(df: Series) -> np.float64: + def _mean(df: Series) -> float: return df.mean() check(assert_type(S.rolling(10).apply(_mean), Series), Series) @@ -163,7 +163,7 @@ def test_rolling_aggregate_series() -> None: check(assert_type(S.rolling(10).aggregate(np.mean), Series), Series) check(assert_type(S.rolling(10).aggregate("mean"), Series), Series) - def _mean(s: Series) -> np.float64: + def _mean(s: Series) -> float: return s.mean() check(assert_type(S.rolling(10).aggregate(_mean), Series), Series) @@ -256,7 +256,7 @@ def test_expanding_basic_math_series() -> None: def test_expanding_apply_series() -> None: check(assert_type(S.expanding(10).apply(np.mean), Series), Series) - def _mean(df: Series) -> np.float64: + def _mean(df: Series) -> float: return df.mean() check(assert_type(S.expanding(10).apply(_mean), Series), Series)