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