DataFrame.var

DataFrame.var(numeric_only: bool | None = None) Series

Return variance for each numeric column

Parameters

numeric_only: {True, False, None} Default is None

Which datatype to be returned - True: Returns all values as float64, NaN/NaT values are removed - None: Returns all values as the same dtype where possible, NaN/NaT are removed - False: Returns all values as the same dtype where possible, NaN/NaT are preserved

Returns

pandas.Series

The value of the variance for each numeric column

See Also

:pandas_api_docs:`pandas.DataFrame.var`

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(OPENSEARCH_TEST_CLIENT, 'flights', columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "timestamp", "DestCountry"])
>>> df.var()  
AvgTicketPrice    70964.570234
Cancelled             0.111987
dayOfWeek             3.761279
dtype: float64
>>> df.var(numeric_only=True)
AvgTicketPrice    70964.570234
Cancelled             0.111987
dayOfWeek             3.761279
dtype: float64
>>> df.var(numeric_only=False)  
AvgTicketPrice     70964.6
Cancelled         0.111987
dayOfWeek          3.76128
timestamp              NaT
DestCountry            NaN
dtype: object