57
57
notna ,
58
58
)
59
59
60
- from pandas .core .construction import extract_array
61
-
62
60
bn = import_optional_dependency ("bottleneck" , errors = "warn" )
63
61
_BOTTLENECK_INSTALLED = bn is not None
64
62
_USE_BOTTLENECK = False
@@ -308,9 +306,6 @@ def _get_values(
308
306
# with scalar fill_value. This guarantee is important for the
309
307
# np.where call below
310
308
assert is_scalar (fill_value )
311
- # error: Incompatible types in assignment (expression has type "Union[Any,
312
- # Union[ExtensionArray, ndarray]]", variable has type "ndarray")
313
- values = extract_array (values , extract_numpy = True ) # type: ignore[assignment]
314
309
315
310
mask = _maybe_get_mask (values , skipna , mask )
316
311
@@ -522,12 +517,12 @@ def nanany(
522
517
--------
523
518
>>> from pandas.core import nanops
524
519
>>> s = pd.Series([1, 2])
525
- >>> nanops.nanany(s)
520
+ >>> nanops.nanany(s.values )
526
521
True
527
522
528
523
>>> from pandas.core import nanops
529
524
>>> s = pd.Series([np.nan])
530
- >>> nanops.nanany(s)
525
+ >>> nanops.nanany(s.values )
531
526
False
532
527
"""
533
528
if needs_i8_conversion (values .dtype ) and values .dtype .kind != "m" :
@@ -577,12 +572,12 @@ def nanall(
577
572
--------
578
573
>>> from pandas.core import nanops
579
574
>>> s = pd.Series([1, 2, np.nan])
580
- >>> nanops.nanall(s)
575
+ >>> nanops.nanall(s.values )
581
576
True
582
577
583
578
>>> from pandas.core import nanops
584
579
>>> s = pd.Series([1, 0])
585
- >>> nanops.nanall(s)
580
+ >>> nanops.nanall(s.values )
586
581
False
587
582
"""
588
583
if needs_i8_conversion (values .dtype ) and values .dtype .kind != "m" :
@@ -637,7 +632,7 @@ def nansum(
637
632
--------
638
633
>>> from pandas.core import nanops
639
634
>>> s = pd.Series([1, 2, np.nan])
640
- >>> nanops.nansum(s)
635
+ >>> nanops.nansum(s.values )
641
636
3.0
642
637
"""
643
638
values , mask , dtype , dtype_max , _ = _get_values (
@@ -705,7 +700,7 @@ def nanmean(
705
700
--------
706
701
>>> from pandas.core import nanops
707
702
>>> s = pd.Series([1, 2, np.nan])
708
- >>> nanops.nanmean(s)
703
+ >>> nanops.nanmean(s.values )
709
704
1.5
710
705
"""
711
706
values , mask , dtype , dtype_max , _ = _get_values (
@@ -761,7 +756,7 @@ def nanmedian(values, *, axis: AxisInt | None = None, skipna: bool = True, mask=
761
756
--------
762
757
>>> from pandas.core import nanops
763
758
>>> s = pd.Series([1, np.nan, 2, 2])
764
- >>> nanops.nanmedian(s)
759
+ >>> nanops.nanmedian(s.values )
765
760
2.0
766
761
"""
767
762
@@ -928,7 +923,7 @@ def nanstd(
928
923
--------
929
924
>>> from pandas.core import nanops
930
925
>>> s = pd.Series([1, np.nan, 2, 3])
931
- >>> nanops.nanstd(s)
926
+ >>> nanops.nanstd(s.values )
932
927
1.0
933
928
"""
934
929
if values .dtype == "M8[ns]" :
@@ -944,7 +939,7 @@ def nanstd(
944
939
@disallow ("M8" , "m8" )
945
940
@bottleneck_switch (ddof = 1 )
946
941
def nanvar (
947
- values ,
942
+ values : np . ndarray ,
948
943
* ,
949
944
axis : AxisInt | None = None ,
950
945
skipna : bool = True ,
@@ -975,10 +970,9 @@ def nanvar(
975
970
--------
976
971
>>> from pandas.core import nanops
977
972
>>> s = pd.Series([1, np.nan, 2, 3])
978
- >>> nanops.nanvar(s)
973
+ >>> nanops.nanvar(s.values )
979
974
1.0
980
975
"""
981
- values = extract_array (values , extract_numpy = True )
982
976
dtype = values .dtype
983
977
mask = _maybe_get_mask (values , skipna , mask )
984
978
if is_any_int_dtype (dtype ):
@@ -1050,7 +1044,7 @@ def nansem(
1050
1044
--------
1051
1045
>>> from pandas.core import nanops
1052
1046
>>> s = pd.Series([1, np.nan, 2, 3])
1053
- >>> nanops.nansem(s)
1047
+ >>> nanops.nansem(s.values )
1054
1048
0.5773502691896258
1055
1049
"""
1056
1050
# This checks if non-numeric-like data is passed with numeric_only=False
@@ -1229,12 +1223,9 @@ def nanskew(
1229
1223
--------
1230
1224
>>> from pandas.core import nanops
1231
1225
>>> s = pd.Series([1, np.nan, 1, 2])
1232
- >>> nanops.nanskew(s)
1226
+ >>> nanops.nanskew(s.values )
1233
1227
1.7320508075688787
1234
1228
"""
1235
- # error: Incompatible types in assignment (expression has type "Union[Any,
1236
- # Union[ExtensionArray, ndarray]]", variable has type "ndarray")
1237
- values = extract_array (values , extract_numpy = True ) # type: ignore[assignment]
1238
1229
mask = _maybe_get_mask (values , skipna , mask )
1239
1230
if not is_float_dtype (values .dtype ):
1240
1231
values = values .astype ("f8" )
@@ -1319,12 +1310,9 @@ def nankurt(
1319
1310
--------
1320
1311
>>> from pandas.core import nanops
1321
1312
>>> s = pd.Series([1, np.nan, 1, 3, 2])
1322
- >>> nanops.nankurt(s)
1313
+ >>> nanops.nankurt(s.values )
1323
1314
-1.2892561983471076
1324
1315
"""
1325
- # error: Incompatible types in assignment (expression has type "Union[Any,
1326
- # Union[ExtensionArray, ndarray]]", variable has type "ndarray")
1327
- values = extract_array (values , extract_numpy = True ) # type: ignore[assignment]
1328
1316
mask = _maybe_get_mask (values , skipna , mask )
1329
1317
if not is_float_dtype (values .dtype ):
1330
1318
values = values .astype ("f8" )
@@ -1413,7 +1401,7 @@ def nanprod(
1413
1401
--------
1414
1402
>>> from pandas.core import nanops
1415
1403
>>> s = pd.Series([1, 2, 3, np.nan])
1416
- >>> nanops.nanprod(s)
1404
+ >>> nanops.nanprod(s.values )
1417
1405
6.0
1418
1406
"""
1419
1407
mask = _maybe_get_mask (values , skipna , mask )
0 commit comments