Question: Hi, would like to ask help on a code. Given that I have a dataframe at this format: vocabulary = [list of unique words] email_spam
Hi, would like to ask help on a code.
Given that I have a dataframe at this format:
vocabulary = [list of unique words]
| email_spam | content |
| 1 | [hi, jack, how, are, you] |
| 0 | [hi, age, how, man, two] |
| 1 | [hello, jack, hello, hello] |
How do I make a table that looks like this?
- The columns are the unique vocabulary in the dataset.
- The row is still the same order. Same index.
- The values inside are the occurrence of the word in column content.
| hi | jack | how | are | you | age | man | two | hello | |
| 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |
Would really appreciate the exact Python code. Thank you!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
