Return the mean of the values over the requested axis.
Axis for the function to be applied on. For Series this parameter is unused and defaults to 0.
For DataFrames, specifying axis=None will apply the aggregation across both axes.
Added in version 2.0.0.
Exclude NA/null values when computing the result.
Include only float, int, boolean columns. Not implemented for Series.
Additional keyword arguments to be passed to the function.
Examples
>>> s = pd.Series([1, 2, 3])
>>> s.mean()
2.0
With 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: float64
Using axis=1
>>> df.mean(axis=1)
tiger 1.5
zebra 2.5
dtype: float64
In 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: float64
© 2008–2011, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
© 2011–2025, Open source contributors
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/2.3.0/reference/api/pandas.DataFrame.mean.html