@@ -12065,7 +12065,6 @@ def var(
12065
12065
) -> Series | Any : ...
12066
12066
12067
12067
@deprecate_nonkeyword_arguments (version = "3.0" , allowed_args = ["self" ], name = "var" )
12068
- @doc (make_doc ("var" , ndim = 2 ))
12069
12068
def var (
12070
12069
self ,
12071
12070
axis : Axis | None = 0 ,
@@ -12074,6 +12073,75 @@ def var(
12074
12073
numeric_only : bool = False ,
12075
12074
** kwargs ,
12076
12075
) -> Series | Any :
12076
+ """
12077
+ Return unbiased variance over requested axis.
12078
+
12079
+ Normalized by N-1 by default. This can be changed using the ddof argument.
12080
+
12081
+ Parameters
12082
+ ----------
12083
+ axis : {index (0), columns (1)}
12084
+ For `Series` this parameter is unused and defaults to 0.
12085
+
12086
+ .. warning::
12087
+
12088
+ The behavior of DataFrame.var with ``axis=None`` is deprecated,
12089
+ in a future version this will reduce over both axes and return a scalar
12090
+ To retain the old behavior, pass axis=0 (or do not pass axis).
12091
+
12092
+ skipna : bool, default True
12093
+ Exclude NA/null values. If an entire row/column is NA, the result
12094
+ will be NA.
12095
+ ddof : int, default 1
12096
+ Delta Degrees of Freedom. The divisor used in calculations is N - ddof,
12097
+ where N represents the number of elements.
12098
+ numeric_only : bool, default False
12099
+ Include only float, int, boolean columns. Not implemented for Series.
12100
+ **kwargs :
12101
+ Additional keywords passed.
12102
+
12103
+ Returns
12104
+ -------
12105
+ Series or scalaer
12106
+ Unbiased variance over requested axis.
12107
+
12108
+ See Also
12109
+ --------
12110
+ numpy.var : Equivalent function in NumPy.
12111
+ Series.var : Return unbiased variance over Series values.
12112
+ Series.std : Return standard deviation over Series values.
12113
+ DataFrame.std : Return standard deviation of the values over
12114
+ the requested axis.
12115
+
12116
+ Examples
12117
+ --------
12118
+ >>> df = pd.DataFrame(
12119
+ ... {
12120
+ ... "person_id": [0, 1, 2, 3],
12121
+ ... "age": [21, 25, 62, 43],
12122
+ ... "height": [1.61, 1.87, 1.49, 2.01],
12123
+ ... }
12124
+ ... ).set_index("person_id")
12125
+ >>> df
12126
+ age height
12127
+ person_id
12128
+ 0 21 1.61
12129
+ 1 25 1.87
12130
+ 2 62 1.49
12131
+ 3 43 2.01
12132
+
12133
+ >>> df.var()
12134
+ age 352.916667
12135
+ height 0.056367
12136
+ dtype: float64
12137
+
12138
+ Alternatively, ``ddof=0`` can be set to normalize by N instead of N-1:
12139
+
12140
+ >>> df.var(ddof=0)
12141
+ age 264.687500
12142
+ height 0.042275
12143
+ dtype: float64
12144
+ """
12077
12145
result = super ().var (
12078
12146
axis = axis , skipna = skipna , ddof = ddof , numeric_only = numeric_only , ** kwargs
12079
12147
)
0 commit comments