.min()
StevenSwiniarski474 total contributions
Published Jun 11, 2022
Contribute to Docs
The .min()
method produces a new Series
or DataFrame
with minimum values for the groups in a GroupBy
object.
Syntax
groupbyobject.min(numeric_only, min_count)
The .min()
method has the following parameters:
numeric_only
: Boolean value.True
includes only int, float, and boolean columns. Default value isTrue
.min_count
: Int value. Required number of valid entries in order to produce a result. Default value is 0.
Example
The following example produces a GroupBy
object from a DataFrame
and executes the .min()
method on it.
import pandas as pddf = pd.DataFrame({'Key' : ['A', 'A', 'A', 'B', 'B', 'C'],'Value' : [15., 23., 17., 5., 8., 12.]})print(df, end='\n\n')group = df.groupby(['Key'], as_index=False)print(group.min())
This example produces the following output:
Key Value0 A 15.01 A 23.02 A 17.03 B 5.04 B 8.05 C 12.0Key Value0 A 15.01 B 5.02 C 12.0
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.