PyLegendStrictDateCollection

PyLegendStrictDateCollection overrides max, min, and distinct_value to return PyLegendStrictDate. Inherits count and distinct_count from PyLegendDateCollection.

count

PyLegendPrimitiveCollection.count()[source]

Count the number of rows in the group.

Returns:

The row count for each group.

Return type:

PyLegendInteger

Examples

Download Interactive Notebook

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

PyLegendPrimitiveCollection.distinct_count()[source]

Count the number of distinct values in the group.

Returns:

The distinct value count for each group.

Return type:

PyLegendInteger

Examples

Download Interactive Notebook

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

PyLegendStrictDateCollection.distinct_value()[source]

Return the single distinct strict date in the group.

Return type:

PyLegendStrictDate

Examples

Download Interactive Notebook

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

PyLegendStrictDateCollection.max()[source]

Latest (maximum) strict date in the group.

Return type:

PyLegendStrictDate

Examples

Download Interactive Notebook

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

PyLegendStrictDateCollection.min()[source]

Earliest (minimum) strict date in the group.

Return type:

PyLegendStrictDate

Examples

Download Interactive Notebook

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