Skip to content

Commit be8ac1a

Browse files
committed
Add exercises on pandas operations
1 parent 2525d67 commit be8ac1a

File tree

2 files changed

+570
-0
lines changed

2 files changed

+570
-0
lines changed
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"## Exercises on pandas operations\n",
8+
"\n",
9+
"\n",
10+
"This notebooks contains some exercises to practice the concepts learned in the notebook [02 - pandas operations](02%20-%20pandas%20operations.ipynb) as well as [01 - pandas basics](01%20-%20pandas%20basics.ipynb).\n",
11+
"\n",
12+
"#### Instructions & suggestions\n",
13+
"\n",
14+
"- Run the first cell below these instructions to load the data\n",
15+
"- For more complex questions, you can iteratively build your solution starting from the simpler pieces \n",
16+
"- There are enough questions to go overtime, feel free to take some of them home"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": null,
22+
"metadata": {},
23+
"outputs": [],
24+
"source": [
25+
"%matplotlib inline\n",
26+
"\n",
27+
"import pandas as pd\n",
28+
"import numpy as np\n",
29+
"\n",
30+
"clients_file = '../data/fake_shop/fake_clients.csv'\n",
31+
"transactions_file = '../data/fake_shop/fake_transactions.csv'\n",
32+
"\n",
33+
"clients = pd.read_csv(clients_file, parse_dates=['date_of_birth'])\n",
34+
"transactions = pd.read_csv(transactions_file, parse_dates=['date'])"
35+
]
36+
},
37+
{
38+
"cell_type": "markdown",
39+
"metadata": {},
40+
"source": [
41+
"### List the number of customers per city"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": null,
47+
"metadata": {},
48+
"outputs": [],
49+
"source": []
50+
},
51+
{
52+
"cell_type": "markdown",
53+
"metadata": {},
54+
"source": [
55+
"### Which product brings in the highest revenue?"
56+
]
57+
},
58+
{
59+
"cell_type": "code",
60+
"execution_count": null,
61+
"metadata": {},
62+
"outputs": [],
63+
"source": []
64+
},
65+
{
66+
"cell_type": "markdown",
67+
"metadata": {},
68+
"source": [
69+
"### List the revenue (sum of the total) per day"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"metadata": {},
76+
"outputs": [],
77+
"source": []
78+
},
79+
{
80+
"cell_type": "markdown",
81+
"metadata": {},
82+
"source": [
83+
"### List the number of transactions per day"
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {},
90+
"outputs": [],
91+
"source": []
92+
},
93+
{
94+
"cell_type": "markdown",
95+
"metadata": {},
96+
"source": [
97+
"### Plot the number of clients per city (in alphabetical order)\n",
98+
"\n",
99+
"Plot with `kind='bar'` to product a bar chart."
100+
]
101+
},
102+
{
103+
"cell_type": "code",
104+
"execution_count": null,
105+
"metadata": {},
106+
"outputs": [],
107+
"source": []
108+
},
109+
{
110+
"cell_type": "markdown",
111+
"metadata": {},
112+
"source": [
113+
"### List the revenue (sum of the total) per city"
114+
]
115+
},
116+
{
117+
"cell_type": "code",
118+
"execution_count": null,
119+
"metadata": {},
120+
"outputs": [],
121+
"source": []
122+
},
123+
{
124+
"cell_type": "markdown",
125+
"metadata": {},
126+
"source": [
127+
"### List the number of transactions per client\n",
128+
"\n",
129+
"Show the client name and the number."
130+
]
131+
},
132+
{
133+
"cell_type": "code",
134+
"execution_count": null,
135+
"metadata": {},
136+
"outputs": [],
137+
"source": []
138+
},
139+
{
140+
"cell_type": "markdown",
141+
"metadata": {},
142+
"source": [
143+
"### Plot the revenue (sum of the total) per city\n",
144+
"\n",
145+
"- Plot using `kind='bar'` to product a bar chart.\n",
146+
"- Add the title \"Revenue per city\" to the plot\n",
147+
"- Add the label \"Revenue\" to the Y-axis"
148+
]
149+
},
150+
{
151+
"cell_type": "code",
152+
"execution_count": null,
153+
"metadata": {},
154+
"outputs": [],
155+
"source": []
156+
},
157+
{
158+
"cell_type": "markdown",
159+
"metadata": {},
160+
"source": [
161+
"### Which product has sold the highest number of units?"
162+
]
163+
},
164+
{
165+
"cell_type": "code",
166+
"execution_count": null,
167+
"metadata": {},
168+
"outputs": [],
169+
"source": []
170+
},
171+
{
172+
"cell_type": "markdown",
173+
"metadata": {},
174+
"source": [
175+
"### Plot the total revenue per product\n",
176+
"\n",
177+
"Plot using `kind='bar'` to product a bar chart."
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": null,
183+
"metadata": {},
184+
"outputs": [],
185+
"source": []
186+
},
187+
{
188+
"cell_type": "markdown",
189+
"metadata": {},
190+
"source": [
191+
"### For each city, list the revenue (sum of total) per product "
192+
]
193+
},
194+
{
195+
"cell_type": "code",
196+
"execution_count": null,
197+
"metadata": {},
198+
"outputs": [],
199+
"source": []
200+
},
201+
{
202+
"cell_type": "markdown",
203+
"metadata": {},
204+
"source": [
205+
"### For each different day, what's the average transaction total?"
206+
]
207+
},
208+
{
209+
"cell_type": "code",
210+
"execution_count": null,
211+
"metadata": {},
212+
"outputs": [],
213+
"source": []
214+
},
215+
{
216+
"cell_type": "markdown",
217+
"metadata": {},
218+
"source": [
219+
"### For each different day, show the minimum and maximum revenue on a single transaction"
220+
]
221+
},
222+
{
223+
"cell_type": "code",
224+
"execution_count": null,
225+
"metadata": {},
226+
"outputs": [],
227+
"source": []
228+
}
229+
],
230+
"metadata": {
231+
"kernelspec": {
232+
"display_name": "Python 3",
233+
"language": "python",
234+
"name": "python3"
235+
},
236+
"language_info": {
237+
"codemirror_mode": {
238+
"name": "ipython",
239+
"version": 3
240+
},
241+
"file_extension": ".py",
242+
"mimetype": "text/x-python",
243+
"name": "python",
244+
"nbconvert_exporter": "python",
245+
"pygments_lexer": "ipython3",
246+
"version": "3.7.4"
247+
}
248+
},
249+
"nbformat": 4,
250+
"nbformat_minor": 2
251+
}

0 commit comments

Comments
 (0)