<jupyter_start><jupyter_text>Student Alcohol Consumption  Introduction:This time you will download a dataset from the UCI. Step 1. Import the necessary libraries<jupyter_code>import pandas as pd
import numpy<jupyter_output><empty_output><jupyter_text>Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/04_Apply/Students_Alcohol_Consumption/student-mat.csv).  Step 3. Assign it to a variable called df.<jupyter_code>url = "https://raw.githubusercontent.com/guipsamora/pandas_exercises/master/04_Apply/Students_Alcohol_Consumption/student-mat.csv"
df = pd.read_csv(url)
df.head(5)<jupyter_output><empty_output><jupyter_text>Step 4. For the purpose of this exercise slice the dataframe from 'school' until the 'guardian' column<jupyter_code>df_sliced = df.loc[:, "school":"guardian"]
df_sliced.head(5)<jupyter_output><empty_output><jupyter_text>Step 5. Create a lambda function that will capitalize strings.<jupyter_code>to_upper = lambda s: s.capitalize()<jupyter_output><empty_output><jupyter_text>Step 6. Capitalize both Mjob and Fjob<jupyter_code>df_sliced.Mjob.apply(to_upper)
df_sliced.Fjob.apply(to_upper)<jupyter_output><empty_output><jupyter_text>Step 7. Print the last elements of the data set.<jupyter_code>df_sliced.tail(5)<jupyter_output><empty_output><jupyter_text>Step 8. Did you notice the original dataframe is still lowercase? Why is that? Fix it and capitalize Mjob and Fjob.<jupyter_code>df_sliced.Mjob = df_sliced.Mjob.apply(to_upper)
df_sliced.Fjob = df_sliced.Fjob.apply(to_upper)
df_sliced.tail(5)<jupyter_output><empty_output><jupyter_text>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)<jupyter_code>is_major = lambda x: True if x > 17 else False 
df_sliced['legal_drinker'] = df_sliced['age'].apply(is_major)
df_sliced.head()<jupyter_output><empty_output><jupyter_text>Step 10. Multiply every number of the dataset by 10.  I know this makes no sense, don't forget it is just an exercise<jupyter_code>df_sliced = df_sliced.applymap(lambda x: 10 * x if type(x) is int else x)
df_sliced.head(10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09738503155996393, 'fraction_numerical': 0.013074842200180343, 'mean_word_length': 7.501915708812261, 'pattern_counts': {'":': 1, '<': 37, '<?xml version=': 0, '>': 38, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '638409', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 829, 'n_tokens_neox': 789, 'n_words': 184, 'path': '04_Apply/Students_Alcohol_Consumption/my_Solutions.ipynb', 'repo_name': 'woldemarg/pandas_exercises', 'size': '2218'}