1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "data": [
10 {
11 "orderId": 1001,
12 "region": "North",
13 "product": "Widget",
14 "amount": "$1,200.00",
15 "orderedAt": "2026-07-03",
16 },
17 {
18 "orderId": 1002,
19 "region": "North",
20 "product": "Gadget",
21 "amount": 350,
22 "orderedAt": "2026-07-18",
23 },
24 {
25 "orderId": 1003,
26 "region": "South",
27 "product": "Widget",
28 "amount": "890.50",
29 "orderedAt": "2026-07-22",
30 },
31 {
32 "orderId": 1004,
33 "region": "south",
34 "product": "Gizmo",
35 "amount": 120,
36 "orderedAt": "2026-08-02",
37 },
38 {
39 "orderId": 1005,
40 "region": "East",
41 "product": "Widget",
42 "amount": 2400,
43 "orderedAt": "2026-08-05",
44 },
45 {
46 "orderId": 1006,
47 "region": "East",
48 "product": "Gadget",
49 "amount": "n/a",
50 "orderedAt": "2026-08-09",
51 },
52 {
53 "orderId": 1007,
54 "region": "North",
55 "product": "Gizmo",
56 "amount": 75,
57 "orderedAt": "2026-08-11",
58 },
59 {
60 "orderId": 1008,
61 "region": "",
62 "product": "Widget",
63 "amount": 410,
64 "orderedAt": "2026-08-14",
65 },
66 ],
67 "groupByFields": ["region"],
68 "aggregations": [
69 {
70 "function": "count",
71 "alias": "orders",
72 },
73 {
74 "field": "amount",
75 "function": "sum",
76 "alias": "total_amount",
77 },
78 {
79 "field": "amount",
80 "function": "avg",
81 "alias": "avg_amount",
82 },
83 ],
84 "exportFormats": [
85 "csv",
86 "xlsx",
87 ],
88}
89
90
91run = client.actor("nerolabs/dataset-aggregate-pivot").call(run_input=run_input)
92
93
94print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
95for item in client.dataset(run.default_dataset_id).iterate_items():
96 print(item)
97
98