Skip to content

Commit c1374d6

Browse files
committed
feat: present data for aggregation operations
1 parent 39ede36 commit c1374d6

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"id": "d69d493a-0716-47e7-bc80-0ef36753fdf8",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": [
10+
"# Introduce Data in Context\n",
11+
"\n",
12+
"orders = [\n",
13+
" (9423517, '2021-08-04', 9001),\n",
14+
" (4626232, '2021-08-04', 9003),\n",
15+
" (9423534, '2021-08-04', 9001),\n",
16+
" (9423679, '2021-08-05', 9002),\n",
17+
" (4626377, '2021-08-05', 9003),\n",
18+
" (4626412, '2021-08-05', 9004),\n",
19+
" (9423783, '2021-08-06', 9002),\n",
20+
" (4626490, '2021-08-06', 9004)\n",
21+
"]\n",
22+
"\n",
23+
"details = [\n",
24+
" (9423517, 'Jeans', 'Rip Curl', 87.0, 1),\n",
25+
" (9423517, 'Jacket', 'The North Face', 112.0, 1),\n",
26+
" (4626232, 'Socks', 'Vans', 15.0, 1),\n",
27+
" (4626232, 'Jeans', 'Quiksilver', 82.0, 1),\n",
28+
" (9423534, 'Socks', 'DC', 10.0, 2),\n",
29+
" (9423534, 'Socks', 'Quiksilver', 12.0, 2),\n",
30+
" (9423679, 'T-shirt', 'Patagonia', 35.0, 1),\n",
31+
" (4626377, 'Hoody', 'Animal', 44.0, 1),\n",
32+
" (4626377, 'Cargo Shorts', 'Animal', 38.0, 1),\n",
33+
" (4626412, 'Shirt', 'Volcom', 78.0, 1),\n",
34+
" (9423783, 'Boxer Shorts', 'Superdry', 30.0, 2),\n",
35+
" (9423783, 'Shorts', 'Globe', 26.0, 1),\n",
36+
" (4626490, 'Cargo Shorts', 'Billabong', 54.0, 1),\n",
37+
" (4626490, 'Sweater', 'Dickies', 56.0, 1)\n",
38+
"]\n",
39+
"\n",
40+
"emps = [\n",
41+
" (9001, 'Jeff Russell', 'LA'),\n",
42+
" (9002, 'Nick Boorman', 'San Francisco'),\n",
43+
" (9003, 'Tom Heints', 'NYC'),\n",
44+
" (9004, 'Maya Silver', 'Philadelphia')\n",
45+
"]\n",
46+
"\n",
47+
"locations = [\n",
48+
" ('LA', 'West'),\n",
49+
" ('San Francisco', 'West'),\n",
50+
" ('NYC', 'East'),\n",
51+
" ('Philadelphia', 'East')\n",
52+
"]"
53+
]
54+
},
55+
{
56+
"cell_type": "code",
57+
"execution_count": 4,
58+
"id": "7302bac8-3643-4701-a1af-ea028dc8af38",
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"import pandas as pd\n",
63+
"\n",
64+
"# Turn each collection into a Pandas DataFrame\n",
65+
"\n",
66+
"df_orders = pd.DataFrame(orders, columns = ['OrderNo', 'Date', 'Empno'])\n",
67+
"df_details = pd.DataFrame(details, columns = ['OrderNo', 'Item', 'Brand', 'Price', 'Quantity'])\n",
68+
"df_emps = pd.DataFrame(emps, columns = ['Empno', 'Empname', 'Location'])\n",
69+
"df_locations = pd.DataFrame(locations, columns = ['Location', 'Region'])"
70+
]
71+
},
72+
{
73+
"cell_type": "markdown",
74+
"id": "9936bb7d-8e2d-45b6-8d62-062b2bbd9749",
75+
"metadata": {},
76+
"source": [
77+
"With every `DataFrame` in place aggregation can be applied based on our queries.\n",
78+
"The goal is to generate the sums of sales by region and date."
79+
]
80+
},
81+
{
82+
"cell_type": "code",
83+
"execution_count": null,
84+
"id": "d93c4011-0731-4992-9863-c198d570e18e",
85+
"metadata": {},
86+
"outputs": [],
87+
"source": []
88+
}
89+
],
90+
"metadata": {
91+
"kernelspec": {
92+
"display_name": "Python 3 (ipykernel)",
93+
"language": "python",
94+
"name": "python3"
95+
},
96+
"language_info": {
97+
"codemirror_mode": {
98+
"name": "ipython",
99+
"version": 3
100+
},
101+
"file_extension": ".py",
102+
"mimetype": "text/x-python",
103+
"name": "python",
104+
"nbconvert_exporter": "python",
105+
"pygments_lexer": "ipython3",
106+
"version": "3.9.17"
107+
}
108+
},
109+
"nbformat": 4,
110+
"nbformat_minor": 5
111+
}

0 commit comments

Comments
 (0)