Question: Let's finally deal with that pesky Export commodities column! It's not a number, but represents a list of items. It is common to deal with

Let's finally deal with that pesky "Export commodities" column! It's not a number, but represents a list of items. It is common to deal with
data that is not numeric (arbitrary strings, strings representing single items, strings representing list/sets of items, etc). To deal with these
non-numeric columns, we need to encode them. That is, we need to convert them from a non-numeric form to a numeric one.
In computer science, there are many encodings and encoding methods. An encoding that you are probably already familiar with is ASCII,
which is a way to represent Latin letters as numbers. Encodings are just agreed upon ways to represent non-numeric values as numbers.
In machine learning and data science, probably the most popular encoding method is the One-Hot encoding. In One-Hot encoding, we take
all the possible values an item can take and assign each possible value an index. Presence of that value results in a 1, which absence results in
a 0. Essentially, we are turning a list of items into a series of binary columns which ask "Do you have this value?".
For example, consider the following tables. In the first one, a student's major is kept as a string (or a list of strings). To encode it, a column is
created for each possible major and a 1 is present if that student has that major (otherwise a 0 is used).
Students:
Students with One-Hot:
Task 3.A
Complete the function below that takes in a frame and a column name. The function should modify the frame to add multiple columns
represented a one-hot encoding of the specified column. Assume that the given column contains a comma-separated list of values. Each
value should be made lowercase and have additional whitespace removed from the beginning and end. The new column names should be
named: "old column name>:
 Let's finally deal with that pesky "Export commodities" column! It's not

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!