技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
Average_Transaction_Value_Stats【数据与研究】Solve average transaction value statistics questions on the dabstep payments dataset. Use this skill for questions that ask for average transaction value/amount grouped by a dimension (e.g., shopper_interaction, issuing_country, acquirer_country, aci), optionally filtered by merchant, card scheme, and/or date range. Triggers on questions like "What i…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
payments.csv is the primary dataset. Key columns:
merchant: Merchant name (e.g., Crossfit_Hanna, Belles_cookbook_store, Golfclub_Baron_Friso, Martinis_Fine_Steakhouse, Rafa_AI)card_scheme: Payment network (e.g., NexPay, GlobalCard, SwiftCharge, TransactPlus)year: Transaction year (all data is 2023)day_of_year: Day 1–365 (no date column — months must be derived from this)eur_amount: Transaction amount in eurosshopper_interaction: Ecommerce or POSissuing_country: Card-issuing country code (SE, NL, LU, IT, BE, FR, GR, ES)acquirer_country: Acquiring bank country codeaci: Authorization Characteristics Indicator (A–G)email_address: Hashed shopper email (can be NaN)When a question says "merchant X's card_scheme Y transactions", filter by BOTH merchant AND card_scheme. Forgetting one filter is the most common error.
df_filtered = df[
(df['merchant'] == 'Merchant_Name') &
(df['card_scheme'] == 'SchemeName') &
(df['day_of_year'] >= start_day) &
(df['day_of_year'] <= end_day)
]
| Month | day_of_year range |
|---|---|
| January | 1 – 31 |
| February | 32 – 59 |
| March | 60 – 90 |
| April | 91 – 120 |
| May | 121 – 151 |
| June | 152 – 181 |
| July | 182 – 212 |
| August | 213 – 243 |
| September | 244 – 273 |
| October | 274 – 304 |
| November | 305 – 334 |
| December | 335 – 365 |
Use the start of the first month and end of the last month as inclusive bounds.
import pandas as pd
df = pd.read_csv('/path/to/payments.csv')
# Step 1: Apply all filters
df_filtered = df[
(df['merchant'] == 'Merchant_Name') & # if specified
(df['card_scheme'] == 'SchemeName') & # if specified
(df['day_of_year'] >= START_DAY) & # if date range given
(df['day_of_year'] <= END_DAY)
]
# Step 2: Group and compute mean
result = (
df_filtered
.groupby('grouping_column')['eur_amount']
.mean()
.round(2)
.sort_values(ascending=True) # always ascending unless stated otherwise
)
# Step 3: Format output
answer = [f"{k}: {v:.2f}" for k, v in result.items()]
The required format [grouping_i: amount_i, ] means a Python list of strings:
['BE: 86.39', 'SE: 91.89', 'ES: 92.83', ...]
"GROUPING_VALUE: AMOUNT" (colon-space separator)101.00 not 101.0)Do NOT return tuples like [('BE', 86.39), ...].
When the question says "average transaction amount per unique email" (or per unique card, etc.):
# Correct: mean of per-group means
per_group_mean = df.groupby('email_address')['eur_amount'].mean()
answer = round(per_group_mean.mean(), 3)
This is NOT total_amount / count_unique_emails. The correct interpretation is:
Before submitting your answer:
day_of_year bounds for the requested months?:?