groupby.DataFrameGroupBy.max

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

Compute the max 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

max value for each numeric column of each group

See Also

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

Examples

>>> from tests import OPENSEARCH_TEST_CLIENT
>>> df = oml.DataFrame(
...   OPENSEARCH_TEST_CLIENT, "flights",
...   columns=["AvgTicketPrice", "Cancelled", "dayOfWeek", "timestamp", "DestCountry"]
... )
>>> df.groupby("DestCountry").max(numeric_only=False) 
             AvgTicketPrice  Cancelled  dayOfWeek           timestamp
DestCountry
AE              1126.148682       True          6 2018-02-11 04:11:14
AR              1199.642822       True          6 2018-02-11 17:09:05
AT              1181.835815       True          6 2018-02-11 23:12:33
AU              1197.632690       True          6 2018-02-11 21:39:01
CA              1198.852539       True          6 2018-02-11 23:04:08
...                     ...        ...        ...                 ...
RU              1196.742310       True          6 2018-02-11 20:03:31
SE              1198.621582       True          6 2018-02-11 22:06:14
TR               855.935547       True          6 2018-02-04 01:59:23
US              1199.729004       True          6 2018-02-11 23:27:00
ZA              1196.186157       True          6 2018-02-11 23:29:45

[32 rows x 4 columns]