Primary
DataFrame.mean() ⚬|Documentation|1st|20251021004927-00-⌔
pandas.DataFrame.mean — pandas 2.3.3 documentation#pandas.DataFrame.mean
DataFrame.mean(﹡, axis=0, skipna=True, numeric_only=False, ﹡﹡kwargs)Return the mean of the values over the requested axis.
Parameters:
axis: {index (0), columns (1)}Axis for the function to be applied on. For Series this parameter is unused and defaults to 0.
For DataFrames, specifying
axis=Nonewill apply the aggregation across both axes.Added in version 2.0.0.
skipna: bool, default TrueExclude NA/null values when computing the result.
numeric_only: bool, default FalseInclude only float, int, boolean columns.
﹡﹡kwargs
Additional keyword arguments to be passed to the function.
Returns:
Series or scalar
Value containing the calculation referenced in the description.
See also:
Series.sumReturn the sum.
Series.minReturn the minimum.
Series.maxReturn the maximum.
Series.idxminReturn the index of the minimum.
Series.idxmaxReturn the index of the maximum.
DataFrame.sumReturn the sum over the requested axis.
DataFrame.minReturn the minimum over the requested axis.
DataFrame.maxReturn the maximum over the requested axis.
DataFrame.idxminReturn the index of the minimum over the requested axis.
DataFrame.idxmaxReturn the index of the maximum over the requested axis.
Examples:
>>> s = pd.Series([1, 2, 3]) >>> s.mean() 2.0With a DataFrame
>>> df = pd.DataFrame({"a": [1, 2], "b": [2, 3]}, index=["tiger", "zebra"]) >>> df a b tiger 1 2 zebra 2 3 >>> df.mean() a 1.5 b 2.5 dtype: float64Using axis=1
>>> df.mean(axis=1) tiger 1.5 zebra 2.5 dtype: float64In this case, numeric_only should be set to True to avoid getting an error.
>>> df = pd.DataFrame({"a": [1, 2], "b": ["T", "Z"]}, index=["tiger", "zebra"]) >>> df.mean(numeric_only=True) a 1.5 dtype: float64Printed 2026-06-28.
(echo:: @ ᯤ)
Link to original
Secondary
• • •