Compute mean of groups, excluding missing values. Parameters ---------- numeric_only : bool, default False Include only float, int, boolean columns. .. versionchanged:: 2.0.0 numeric_only no longer accepts ``None`` and defau
(
self,
numeric_only: bool = False,
skipna: bool = True,
engine: Literal["cython", "numba"] | None = None,
engine_kwargs: dict[str, bool] | None = None,
)
| 2191 | |
| 2192 | @final |
| 2193 | def mean( |
| 2194 | self, |
| 2195 | numeric_only: bool = False, |
| 2196 | skipna: bool = True, |
| 2197 | engine: Literal["cython", "numba"] | None = None, |
| 2198 | engine_kwargs: dict[str, bool] | None = None, |
| 2199 | ): |
| 2200 | """ |
| 2201 | Compute mean of groups, excluding missing values. |
| 2202 | |
| 2203 | Parameters |
| 2204 | ---------- |
| 2205 | numeric_only : bool, default False |
| 2206 | Include only float, int, boolean columns. |
| 2207 | |
| 2208 | .. versionchanged:: 2.0.0 |
| 2209 | |
| 2210 | numeric_only no longer accepts ``None`` and defaults to ``False``. |
| 2211 | |
| 2212 | skipna : bool, default True |
| 2213 | Exclude NA/null values. If an entire group is NA, the result will be NA. |
| 2214 | |
| 2215 | engine : str, default None |
| 2216 | * ``'cython'`` : Runs the operation through C-extensions from cython. |
| 2217 | * ``'numba'`` : Runs the operation through JIT compiled code from numba. |
| 2218 | * ``None`` : Defaults to ``'cython'`` or globally setting |
| 2219 | ``compute.use_numba`` |
| 2220 | |
| 2221 | engine_kwargs : dict, default None |
| 2222 | * For ``'cython'`` engine, there are no accepted ``engine_kwargs`` |
| 2223 | * For ``'numba'`` engine, the engine can accept ``nopython``, ``nogil`` |
| 2224 | and ``parallel`` dictionary keys. The values must either be ``True`` or |
| 2225 | ``False``. The default ``engine_kwargs`` for the ``'numba'`` engine is |
| 2226 | ``{'nopython': True, 'nogil': False, 'parallel': False}`` |
| 2227 | |
| 2228 | Returns |
| 2229 | ------- |
| 2230 | pandas.Series or pandas.DataFrame |
| 2231 | Mean of values within each group. Same object type as the caller. |
| 2232 | |
| 2233 | See Also |
| 2234 | -------- |
| 2235 | Series.mean : Apply function mean to a Series. |
| 2236 | DataFrame.mean : Apply function mean to each row or column of a DataFrame. |
| 2237 | |
| 2238 | Examples |
| 2239 | -------- |
| 2240 | >>> df = pd.DataFrame( |
| 2241 | ... {"A": [1, 1, 2, 1, 2], "B": [np.nan, 2, 3, 4, 5], "C": [1, 2, 1, 1, 2]}, |
| 2242 | ... columns=["A", "B", "C"], |
| 2243 | ... ) |
| 2244 | |
| 2245 | Groupby one column and return the mean of the remaining columns in |
| 2246 | each group. |
| 2247 | |
| 2248 | >>> df.groupby("A").mean() |
| 2249 | B C |
| 2250 | A |
nothing calls this directly
no test coverage detected