@@ -6720,7 +6720,6 @@ def sem(
67206720 )
67216721
67226722 @deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "var" )
6723- @doc (make_doc ("var" , ndim = 1 ))
67246723 def var (
67256724 self ,
67266725 axis : Axis | None = None ,
@@ -6729,6 +6728,75 @@ def var(
67296728 numeric_only : bool = False ,
67306729 ** kwargs ,
67316730 ):
6731+ """
6732+ Return unbiased variance over requested axis.
6733+
6734+ Normalized by N-1 by default. This can be changed using the ddof argument.
6735+
6736+ Parameters
6737+ ----------
6738+ axis : {index (0)}
6739+ For `Series` this parameter is unused and defaults to 0.
6740+
6741+ .. warning::
6742+
6743+ The behavior of DataFrame.var with ``axis=None`` is deprecated,
6744+ in a future version this will reduce over both axes and return a scalar
6745+ To retain the old behavior, pass axis=0 (or do not pass axis).
6746+
6747+ skipna : bool, default True
6748+ Exclude NA/null values. If an entire row/column is NA, the result
6749+ will be NA.
6750+ ddof : int, default 1
6751+ Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
6752+ where N represents the number of elements.
6753+ numeric_only : bool, default False
6754+ Include only float, int, boolean columns. Not implemented for Series.
6755+ **kwargs :
6756+ Additional keywords passed.
6757+
6758+ Returns
6759+ -------
6760+ scalar or Series (if level specified)
6761+ Unbiased variance over requested axis.
6762+
6763+ See Also
6764+ --------
6765+ numpy.var : Equivalent function in NumPy.
6766+ Series.std : Returns the standard deviation of the Series.
6767+ DataFrame.var : Returns the variance of the DataFrame.
6768+ DataFrame.std : Return standard deviation of the values over
6769+ the requested axis.
6770+
6771+ Examples
6772+ --------
6773+ >>> df = pd.DataFrame(
6774+ ... {
6775+ ... "person_id": [0, 1, 2, 3],
6776+ ... "age": [21, 25, 62, 43],
6777+ ... "height": [1.61, 1.87, 1.49, 2.01],
6778+ ... }
6779+ ... ).set_index("person_id")
6780+ >>> df
6781+ age height
6782+ person_id
6783+ 0 21 1.61
6784+ 1 25 1.87
6785+ 2 62 1.49
6786+ 3 43 2.01
6787+
6788+ >>> df.var()
6789+ age 352.916667
6790+ height 0.056367
6791+ dtype: float64
6792+
6793+ Alternatively, ``ddof=0`` can be set to normalize by N instead of N-1:
6794+
6795+ >>> df.var(ddof=0)
6796+ age 264.687500
6797+ height 0.042275
6798+ dtype: float64
6799+ """
67326800 return NDFrame .var (
67336801 self ,
67346802 axis = axis ,
0 commit comments