Path: blob/master/04_Apply/Students_Alcohol_Consumption/Solutions.ipynb
548 views
Kernel: Python [default]
Student Alcohol Consumption
Introduction:
This time you will download a dataset from the UCI.
Step 1. Import the necessary libraries
In [1]:
Step 2. Import the dataset from this address.
Step 3. Assign it to a variable called df.
In [2]:
Out[2]:
Step 4. For the purpose of this exercise slice the dataframe from 'school' until the 'guardian' column
In [3]:
Out[3]:
Step 5. Create a lambda function that will capitalize strings.
In [10]:
Step 6. Capitalize both Mjob and Fjob
In [11]:
Out[11]:
0 Teacher
1 Other
2 Other
3 Services
4 Other
5 Other
6 Other
7 Teacher
8 Other
9 Other
10 Health
11 Other
12 Services
13 Other
14 Other
15 Other
16 Services
17 Other
18 Services
19 Other
20 Other
21 Health
22 Other
23 Other
24 Health
25 Services
26 Other
27 Services
28 Other
29 Teacher
...
365 Other
366 Services
367 Services
368 Services
369 Teacher
370 Services
371 Services
372 At_home
373 Other
374 Other
375 Other
376 Other
377 Services
378 Other
379 Other
380 Teacher
381 Other
382 Services
383 Services
384 Other
385 Other
386 At_home
387 Other
388 Services
389 Other
390 Services
391 Services
392 Other
393 Other
394 At_home
Name: Fjob, dtype: object
Step 7. Print the last elements of the data set.
In [12]:
Out[12]:
Step 8. Did you notice the original dataframe is still lowercase? Why is that? Fix it and capitalize Mjob and Fjob.
In [13]:
Out[13]:
Step 9. Create a function called majority that returns a boolean value to a new column called legal_drinker (Consider majority as older than 17 years old)
In [14]:
In [15]:
Out[15]:
Step 10. Multiply every number of the dataset by 10.
I know this makes no sense, don't forget it is just an exercise
In [16]:
In [17]:
Out[17]: