Thomas Eapen · Selected work

One grouping, two measures

Use the same grouping structure to compare related counts without mixing their meaning.

Synthetic example · independently invented dataOne-page print edition · A3 landscape
01 Inspect the inputs02 Apply the method03 Check the result

INVENTED INPUTS

Repeated reporting groups

Six synthetic group/path records
GroupPathEventsHandoffs
ADirect182
ADirect121
AAssisted104
BDirect161
BAssisted143
BAssisted62

Repeated rows for a group and path contribute to the same subtotal. Both measures are additive counts.

SELECTED PYTHON

The working calculation

Pandas is pd. rows contains the six input records; counts are already numeric.

data = pd.DataFrame(rows)
summary = data.pivot_table(
    index='group', columns='path',
    values=['events', 'handoffs'],
    aggfunc='sum', fill_value=0
)

The code shown here is executed to calculate this example’s results.

COMPUTED RESULT

Two aligned pivot views

Event counts by path
GroupAssistedDirect
Group A1030
Group B2016
Handoff counts by path
GroupAssistedDirect
Group A43
Group B51
76 / 13events / handoffsTotals across both groups and paths

The columns have the same meaning in both views, so the reader can compare their distribution directly.

What this demonstratesA shared grouping structure makes related measures easier to compare. Naming the aggregation prevents a default mean from changing the question.

Check the boundarySumming counts is appropriate here. Rates and averages require a different aggregation rule, often using their underlying denominators.