groupby.DataFrameGroupBy.std

DataFrameGroupBy.std(numeric_only: bool = True) pd.DataFrame[source]

Compute the standard deviation value for each group.

Parameters

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

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.DataFrame

standard deviation value for each numeric column of each group

See Also

:pandas_api_docs:`pandas.core.groupby.GroupBy.std`

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(
...   OPENSEARCH_TEST_CLIENT, "flights",
...   columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "DestCountry"]
... )
>>> df.groupby("DestCountry").std() 
             AvgTicketPrice  Cancelled  dayOfWeek
DestCountry
AE               279.875500   0.367171   2.020634
AR               244.903626   0.355811   1.949901
AT               256.883342   0.381035   2.026411
AU               255.585377   0.336902   1.961486
CA               261.263054   0.341587   1.921980
...                     ...        ...        ...
RU               259.696213   0.338140   1.964815
SE               232.504297   0.357510   1.991340
TR               267.827572   0.333333   2.191454
US               272.774819   0.331242   1.939469
ZA               251.505568   0.356766   1.948258

[32 rows x 3 columns]