PyLegendIntegerCollection
PyLegendIntegerCollection overrides max, min, sum, and
distinct_value to return PyLegendInteger instead of
PyLegendNumber. All other aggregation methods are inherited from
PyLegendNumberCollection.
average
Arithmetic mean of the values in the group.
- Return type:
PyLegendFloat
See also
meanAlias for
average.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.average() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 10838.4 1 Alfreds Futterkiste 10643.0 2 Ana Trujillo Emparedados y helados 10654.5
count
Count the number of rows in the group.
- Returns:
The row count for each group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.count() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 5 1 Alfreds Futterkiste 1 2 Ana Trujillo Emparedados y helados 4
distinct_count
Count the number of distinct values in the group.
- Returns:
The distinct value count for each group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.distinct_count() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 5 1 Alfreds Futterkiste 1 2 Ana Trujillo Emparedados y helados 4
distinct_value
Return the single distinct integer value in the group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Order Id")["Order Id"].aggregate( lambda x: x.distinct_value() ).to_pandas().head(3)
Order Id lambda_0(Order Id) 0 10248 10248 1 10249 10249 2 10250 10250
max
Maximum integer value in the group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.max() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 11011 1 Alfreds Futterkiste 10643 2 Ana Trujillo Emparedados y helados 10926
mean
Alias for
average().- Return type:
PyLegendFloat
median
Median of the values in the group.
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.median() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 10835.0 1 Alfreds Futterkiste 10643.0 2 Ana Trujillo Emparedados y helados 10692.0
min
Minimum integer value in the group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.min() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 10692 1 Alfreds Futterkiste 10643 2 Ana Trujillo Emparedados y helados 10308
percentile
Compute a percentile of the values in the group.
- Parameters:
percentile (
float) – The percentile to compute, between 0 and 1.ascending (
bool) – IfTrue, values are sorted in ascending order before computing the percentile.continuous (
bool) – IfTrue, use continuous (interpolated) percentile (PERCENTILE_CONT). IfFalse, use discrete (PERCENTILE_DISC).
- Return type:
PyLegendNumber
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.percentile(0.5) ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 10835.0 1 Alfreds Futterkiste 10643.0 2 Ana Trujillo Emparedados y helados 10692.0
row_mapper
Pair this collection with another numeric value for bivariate aggregations (correlation, covariance, weighted average).
- Parameters:
other (
Union[int,float,PyLegendInteger,PyLegendFloat,PyLegendDecimal,PyLegendNumber,PyLegendNumberCollection]) – The second numeric operand.- Returns:
A paired collection supporting
corr,covar_sample,covar_population, andwavg_legend_ext.- Return type:
PyLegendNumberPairCollection
std_dev
Alias for
std_dev_sample().- Return type:
PyLegendNumber
std_dev_population
Population standard deviation of the values in the group.
- Return type:
PyLegendNumber
See also
std_dev_sampleSample standard deviation.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.std_dev_population() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 128.643072 1 Alfreds Futterkiste 0.0 2 Ana Trujillo Emparedados y helados 226.696383
std_dev_sample
Sample standard deviation of the values in the group.
- Return type:
PyLegendNumber
See also
std_devAlias for
std_dev_sample.std_dev_populationPopulation standard deviation.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.std_dev_sample() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 143.827327 1 Alfreds Futterkiste <NA> 2 Ana Trujillo Emparedados y helados 261.766435
sum
Sum of the integer values in the group.
- Return type:
PyLegendInteger
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.sum() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 54192 1 Alfreds Futterkiste 10643 2 Ana Trujillo Emparedados y helados 42618
variance
Alias for
variance_sample().- Return type:
PyLegendNumber
variance_population
Population variance of the values in the group.
- Return type:
PyLegendNumber
See also
variance_sampleSample variance.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.variance_population() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 16549.04 1 Alfreds Futterkiste 0.0 2 Ana Trujillo Emparedados y helados 51391.25
variance_sample
Sample variance of the values in the group.
- Return type:
PyLegendNumber
See also
varianceAlias for
variance_sample.variance_populationPopulation variance.
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Order Id"].aggregate( lambda x: x.variance_sample() ).to_pandas().head(3)
Ship Name Order Id 0 Alfred's Futterkiste 20686.3 1 Alfreds Futterkiste <NA> 2 Ana Trujillo Emparedados y helados 68521.666667