Skip to content

Commit beca53e

Browse files
committed
fixed solution of visualizing chipo exercise
1 parent 360f2d8 commit beca53e

File tree

1 file changed

+6
-51
lines changed

1 file changed

+6
-51
lines changed

07_Visualization/Chipotle/Solutions.ipynb

+6-51
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@
5050
"execution_count": 2,
5151
"metadata": {},
5252
"outputs": [],
53-
"source": [
54-
"url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv'\n",
55-
" \n",
56-
"chipo = pd.read_csv(url, sep = '\\t')"
57-
]
53+
"source": []
5854
},
5955
{
6056
"cell_type": "markdown",
@@ -214,9 +210,7 @@
214210
"output_type": "execute_result"
215211
}
216212
],
217-
"source": [
218-
"chipo.head(10)"
219-
]
213+
"source": []
220214
},
221215
{
222216
"cell_type": "markdown",
@@ -243,30 +237,7 @@
243237
"output_type": "display_data"
244238
}
245239
],
246-
"source": [
247-
"# get the Series of the names\n",
248-
"x = chipo.item_name\n",
249-
"\n",
250-
"# use the Counter class from collections to create a dictionary with keys(text) and frequency\n",
251-
"letter_counts = Counter(x)\n",
252-
"\n",
253-
"# convert the dictionary to a DataFrame\n",
254-
"df = pd.DataFrame.from_dict(letter_counts, orient='index')\n",
255-
"\n",
256-
"# sort the values from the top to the least value and slice the first 5 items\n",
257-
"df = df[0].sort_values(ascending = True)[45:50]\n",
258-
"\n",
259-
"# create the plot\n",
260-
"df.plot(kind='bar')\n",
261-
"\n",
262-
"# Set the title and labels\n",
263-
"plt.xlabel('Items')\n",
264-
"plt.ylabel('Number of Times Ordered')\n",
265-
"plt.title('Most ordered Chipotle\\'s Items')\n",
266-
"\n",
267-
"# show the plot\n",
268-
"plt.show()"
269-
]
240+
"source": []
270241
},
271242
{
272243
"cell_type": "markdown",
@@ -304,23 +275,7 @@
304275
"output_type": "display_data"
305276
}
306277
],
307-
"source": [
308-
"# create a list of prices\n",
309-
"chipo.item_price = [float(value[1:-1]) for value in chipo.item_price] # strip the dollar sign and trailing space\n",
310-
"\n",
311-
"# then groupby the orders and sum\n",
312-
"orders = chipo.groupby('order_id').sum()\n",
313-
"\n",
314-
"# creates the scatterplot\n",
315-
"# plt.scatter(orders.quantity, orders.item_price, s = 50, c = 'green')\n",
316-
"plt.scatter(x = orders.item_price, y = orders.quantity, s = 50, c = 'green')\n",
317-
"\n",
318-
"# Set the title and labels\n",
319-
"plt.xlabel('Order Price')\n",
320-
"plt.ylabel('Items ordered')\n",
321-
"plt.title('Number of items ordered per order price')\n",
322-
"plt.ylim(0)"
323-
]
278+
"source": []
324279
},
325280
{
326281
"cell_type": "markdown",
@@ -353,9 +308,9 @@
353308
"name": "python",
354309
"nbconvert_exporter": "python",
355310
"pygments_lexer": "ipython3",
356-
"version": "3.6.8"
311+
"version": "3.9.1"
357312
}
358313
},
359314
"nbformat": 4,
360315
"nbformat_minor": 1
361-
}
316+
}

0 commit comments

Comments
 (0)