image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

sarcasm_df = pd.read_csv('../input/sarcasm/train-balanced-sarcasm.csv')

sarcasm_df.dropna(subset=['comment'], inplace=True)
sarcasm_df['comment'] = sarcasm_df['comment'].str.lower()
sarcasm_df['comment'] = sarcasm_df['comment'].str.replace('[^\\w\\s]', '')

sarcasm_df.created_utc = pd.to_datetime(sarcasm_df.created_utc)

plt.figure(figsize=(5,5))
ax = sns.countplot(x='label',  data= sarcasm_df)
ax.set(title = "Distribution of Classes", xlabel="Sarcasm Status", ylabel = "Total Count")
total = float(len(sarcasm_df ))
for p in ax.patches:
    height = p.get_height()
    ax.text(p.get_x()+p.get_width()/2.,
            height + 3,
            '{:1.1f}%'.format((height/total)*100),
            ha="center") 
plt.show()

sns.despine(offset=10, trim=True)

sns.boxplot(x=sarcasm_df.loc[sarcasm_df['label'] == 0, 'comment'].str.len()).set(title='Length of Neutral Comments', xlabel='Length')
sns.despine(offset=10, trim=True)
plt.show()