Exploring the data

In case you have any packages missing, you can install them from the notebook itself by using the following commands:

# !conda install -y pandas# !conda install -y numpy

Let's get the imports out of our way:

import pandas as pdimport numpy as np

Then, read the train file into a pandas DataFrame:

train_df = pd.read_csv("data/train.csv")train_df.head()

We get the following output:

id comment_text toxic severe_toxic obscene threat insult identity_hate
0 0000997932d777bf Explanation\r\nWhy the edits made under my use... 0 0 0 0 0 0
1 000103f0d9cfb60f D'aww! He matches this background colour I'm s... 0 0 0 0 0 0
2 000113f07ec002fd Hey man, I'm really not trying to edit war. It... 0 0 0 0 0 0
3 0001b41b1c6bb37e ...

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.