PyLegendDateTimeCollection

PyLegendDateTimeCollection overrides distinct_value to return PyLegendDateTime. Inherits max, min, 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

PyLegendDateTimeCollection.distinct_value()[source]

Return the single distinct datetime in the group.

Return type:

PyLegendDateTime

Examples

Download Interactive Notebook

import pylegend
frame = pylegend.samples.pandas_api.northwind_orders_frame()
frame["dt"] = frame["Shipped Date"].first_hour_of_day()
frame.groupby("dt")["dt"].aggregate(
    lambda x: x.distinct_value()
).to_pandas().head(3)
dt lambda_0(dt)
0 NaT NaT
1 1996-07-10 1996-07-10
2 1996-07-11 1996-07-11

max

PyLegendDateCollection.max()[source]

Latest (maximum) date in the group.

Return type:

PyLegendDate

Examples

Download Interactive Notebook

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

PyLegendDateCollection.min()[source]

Earliest (minimum) date in the group.

Return type:

PyLegendDate

Examples

Download Interactive Notebook

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