MCPcopy
hub / github.com/pandas-dev/pandas / f

Method f

pandas/core/nanops.py:114–151  ·  view source on GitHub ↗
(
            values: np.ndarray,
            *,
            axis: AxisInt | None = None,
            skipna: bool = True,
            **kwds,
        )

Source from the content-addressed store, hash-verified

112
113 @functools.wraps(alt)
114 def f(
115 values: np.ndarray,
116 *,
117 axis: AxisInt | None = None,
118 skipna: bool = True,
119 **kwds,
120 ):
121 if len(self.kwargs) > 0:
122 for k, v in self.kwargs.items():
123 if k not in kwds:
124 kwds[k] = v
125
126 if values.size == 0 and kwds.get("min_count") is None:
127 # We are empty, returning NA for our type
128 # Only applies for the default `min_count` of None
129 # since that affects how empty arrays are handled.
130 # TODO(GH-18976) update all the nanops methods to
131 # correctly handle empty inputs and remove this check.
132 # It *may* just be `var`
133 return _na_for_min_count(values, axis)
134
135 if _USE_BOTTLENECK and skipna and _bn_ok_dtype(values.dtype, bn_name):
136 if kwds.get("mask", None) is None:
137 # `mask` is not recognised by bottleneck, would raise
138 # TypeError if called
139 kwds.pop("mask", None)
140 result = bn_func(values, axis=axis, **kwds)
141
142 # prefer to treat inf/-inf as NA, but must compute the func
143 # twice :(
144 if _has_infs(result):
145 result = alt(values, axis=axis, skipna=skipna, **kwds)
146 else:
147 result = alt(values, axis=axis, skipna=skipna, **kwds)
148 else:
149 result = alt(values, axis=axis, skipna=skipna, **kwds)
150
151 return result
152
153 return cast(F, f)
154

Callers

nothing calls this directly

Calls 6

_na_for_min_countFunction · 0.85
_bn_ok_dtypeFunction · 0.85
_has_infsFunction · 0.85
itemsMethod · 0.45
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected