PyLegendDateCollection
PyLegendDateCollection provides max, min, and
distinct_value aggregations for date columns. Inherits
count and distinct_count from
PyLegendPrimitiveCollection.
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 date in the group.
- Return type:
PyLegendDate
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Shipped Date")["Shipped Date"].aggregate( lambda x: x.distinct_value() ).to_pandas().head(3)
Shipped Date lambda_0(Shipped Date) 0 NaT NaT 1 1996-07-10 1996-07-10 2 1996-07-11 1996-07-11
max
Latest (maximum) date in the group.
- Return type:
PyLegendDate
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Shipped Date"].aggregate( lambda x: x.max() ).to_pandas().head(3)
Ship Name Shipped Date 0 Alfred's Futterkiste 1998-04-13 1 Alfreds Futterkiste 1997-09-02 2 Ana Trujillo Emparedados y helados 1998-03-11
min
Earliest (minimum) date in the group.
- Return type:
PyLegendDate
Examples
import pylegend frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame.groupby("Ship Name")["Shipped Date"].aggregate( lambda x: x.min() ).to_pandas().head(3)
Ship Name Shipped Date 0 Alfred's Futterkiste 1997-10-13 1 Alfreds Futterkiste 1997-09-02 2 Ana Trujillo Emparedados y helados 1996-09-24