<jupyter_start><jupyter_text>Categorical Variables<jupyter_code>import pandas as pd
df = pd.DataFrame({'salary': [103, 89, 142, 54, 63, 219],
                   'boro': ['Manhatten', 'Queens', 'Manhatten', 'Brooklyn', 'Brooklyn', 'Bronx']})
df
pd.get_dummies(df)
df = pd.DataFrame({'salary': [103, 89, 142, 54, 63, 219],
                   'boro': [0, 1, 0, 2, 2, 3]})
df
pd.get_dummies(df, columns=['boro'])<jupyter_output><empty_output><jupyter_text>ExerciseApply dummy encoding and scaling to the "adult" dataset consisting of income data from the census.Bonus: visualize the data.<jupyter_code>data = pd.read_csv("adult.csv", index_col=0)
# %load solutions/load_adult.py<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16193181818181818, 'fraction_numerical': 0.052556818181818184, 'mean_word_length': 5.184210526315789, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '81912', 'license': 'MIT', 'n_tokens_mistral': 306, 'n_tokens_neox': 260, 'n_words': 62, 'path': 'notebooks/04 - Preprocessing.ipynb', 'repo_name': 'lampsonnguyen/ml-training-intro', 'size': '704'}