Skip to content

Commit 24b3119

Browse files
committed
new deleting exercise - wine
1 parent 490f0c0 commit 24b3119

File tree

4 files changed

+3043
-0
lines changed

4 files changed

+3043
-0
lines changed

10_Deleting/Wine/Exercises.ipynb

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Wine"
8+
]
9+
},
10+
{
11+
"cell_type": "markdown",
12+
"metadata": {},
13+
"source": [
14+
"### Introduction:\n",
15+
"\n",
16+
"This exercise is a adaptation from the UCI Wine dataset.\n",
17+
"The only pupose is to practice deleting data with pandas.\n",
18+
"\n",
19+
"### Step 1. Import the necessary libraries"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"metadata": {
26+
"collapsed": false
27+
},
28+
"outputs": [],
29+
"source": []
30+
},
31+
{
32+
"cell_type": "markdown",
33+
"metadata": {},
34+
"source": [
35+
"### Step 2. Import the dataset from this [address](https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data). "
36+
]
37+
},
38+
{
39+
"cell_type": "markdown",
40+
"metadata": {},
41+
"source": [
42+
"### Step 3. Assign it to a variable called wine"
43+
]
44+
},
45+
{
46+
"cell_type": "code",
47+
"execution_count": null,
48+
"metadata": {
49+
"collapsed": false
50+
},
51+
"outputs": [],
52+
"source": []
53+
},
54+
{
55+
"cell_type": "markdown",
56+
"metadata": {},
57+
"source": [
58+
"### Step 4. Delete the first, fourth, seventh, nineth, eleventh, thirteenth and fourteenth columns"
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {
65+
"collapsed": false
66+
},
67+
"outputs": [],
68+
"source": []
69+
},
70+
{
71+
"cell_type": "markdown",
72+
"metadata": {},
73+
"source": [
74+
"### Step 5. Assign the columns as below:\n",
75+
"\n",
76+
"The attributes are (dontated by Riccardo Leardi, riclea '@' anchem.unige.it): \n",
77+
"1) alcohol \n",
78+
"2) malic_acid \n",
79+
"3) alcalinity_of_ash \n",
80+
"4) magnesium \n",
81+
"5) flavanoids \n",
82+
"6) proanthocyanins \n",
83+
"7) hue "
84+
]
85+
},
86+
{
87+
"cell_type": "code",
88+
"execution_count": null,
89+
"metadata": {
90+
"collapsed": false
91+
},
92+
"outputs": [],
93+
"source": []
94+
},
95+
{
96+
"cell_type": "markdown",
97+
"metadata": {},
98+
"source": [
99+
"### Step 6. Set the values of the first 3 rows from alcohol as NaN"
100+
]
101+
},
102+
{
103+
"cell_type": "code",
104+
"execution_count": null,
105+
"metadata": {
106+
"collapsed": false
107+
},
108+
"outputs": [],
109+
"source": []
110+
},
111+
{
112+
"cell_type": "markdown",
113+
"metadata": {},
114+
"source": [
115+
"### Step 7. Now set the value of the rows 3 and 4 of magnesium as NaN"
116+
]
117+
},
118+
{
119+
"cell_type": "code",
120+
"execution_count": null,
121+
"metadata": {
122+
"collapsed": false
123+
},
124+
"outputs": [],
125+
"source": []
126+
},
127+
{
128+
"cell_type": "markdown",
129+
"metadata": {},
130+
"source": [
131+
"### Step 8. Fill the value of NaN with the number 10 in alcohol and 100 in magnesium"
132+
]
133+
},
134+
{
135+
"cell_type": "code",
136+
"execution_count": null,
137+
"metadata": {
138+
"collapsed": false
139+
},
140+
"outputs": [],
141+
"source": []
142+
},
143+
{
144+
"cell_type": "markdown",
145+
"metadata": {},
146+
"source": [
147+
"### Step 9. Count the number of missing values"
148+
]
149+
},
150+
{
151+
"cell_type": "code",
152+
"execution_count": null,
153+
"metadata": {
154+
"collapsed": false
155+
},
156+
"outputs": [],
157+
"source": []
158+
},
159+
{
160+
"cell_type": "markdown",
161+
"metadata": {},
162+
"source": [
163+
"### Step 10. Create an array of 10 random numbers up until 10"
164+
]
165+
},
166+
{
167+
"cell_type": "code",
168+
"execution_count": null,
169+
"metadata": {
170+
"collapsed": false
171+
},
172+
"outputs": [],
173+
"source": []
174+
},
175+
{
176+
"cell_type": "markdown",
177+
"metadata": {},
178+
"source": [
179+
"### Step 11. Set the rows of the random numbers in the column"
180+
]
181+
},
182+
{
183+
"cell_type": "code",
184+
"execution_count": null,
185+
"metadata": {
186+
"collapsed": false
187+
},
188+
"outputs": [],
189+
"source": []
190+
},
191+
{
192+
"cell_type": "markdown",
193+
"metadata": {},
194+
"source": [
195+
"### Step 12. How many missing values do we have?"
196+
]
197+
},
198+
{
199+
"cell_type": "code",
200+
"execution_count": null,
201+
"metadata": {
202+
"collapsed": false
203+
},
204+
"outputs": [],
205+
"source": []
206+
},
207+
{
208+
"cell_type": "markdown",
209+
"metadata": {},
210+
"source": [
211+
"### Step 14. Print only the non-null values in alcohol"
212+
]
213+
},
214+
{
215+
"cell_type": "code",
216+
"execution_count": null,
217+
"metadata": {
218+
"collapsed": false
219+
},
220+
"outputs": [],
221+
"source": []
222+
},
223+
{
224+
"cell_type": "markdown",
225+
"metadata": {},
226+
"source": [
227+
"### Step 13. Delete the rows that contain missing values"
228+
]
229+
},
230+
{
231+
"cell_type": "code",
232+
"execution_count": null,
233+
"metadata": {
234+
"collapsed": false
235+
},
236+
"outputs": [],
237+
"source": []
238+
},
239+
{
240+
"cell_type": "markdown",
241+
"metadata": {},
242+
"source": [
243+
"### Step 15. Reset the index, so it starts with 0 again"
244+
]
245+
},
246+
{
247+
"cell_type": "code",
248+
"execution_count": null,
249+
"metadata": {
250+
"collapsed": false
251+
},
252+
"outputs": [],
253+
"source": []
254+
},
255+
{
256+
"cell_type": "markdown",
257+
"metadata": {},
258+
"source": [
259+
"### BONUS: Create your own question and answer it."
260+
]
261+
},
262+
{
263+
"cell_type": "code",
264+
"execution_count": null,
265+
"metadata": {
266+
"collapsed": true
267+
},
268+
"outputs": [],
269+
"source": []
270+
}
271+
],
272+
"metadata": {
273+
"kernelspec": {
274+
"display_name": "Python 2",
275+
"language": "python",
276+
"name": "python2"
277+
},
278+
"language_info": {
279+
"codemirror_mode": {
280+
"name": "ipython",
281+
"version": 2
282+
},
283+
"file_extension": ".py",
284+
"mimetype": "text/x-python",
285+
"name": "python",
286+
"nbconvert_exporter": "python",
287+
"pygments_lexer": "ipython2",
288+
"version": "2.7.11"
289+
}
290+
},
291+
"nbformat": 4,
292+
"nbformat_minor": 0
293+
}

0 commit comments

Comments
 (0)