text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

dataset = pd.read_csv('/kaggle/input/arrests-for-marijuana-possession/Arrests.csv')

dataset.drop(dataset.columns[0], axis=1, inplace=True)

dataset['year'] = pd.to_datetime(dataset['year'], format='%Y').dt.year

dataset.isna().sum()

duplicated_entries_df = dataset[dataset.duplicated()]

cat_cols = dataset.select_dtypes(include=['object']).columns.tolist()
value_counts_df = pd.DataFrame(columns=['Column Name', 'Value', 'Count'])
for col in cat_cols:
    value_counts = dataset[col].value_counts().reset_index()
    value_counts.columns = ['Value', 'Count']
    value_counts['Column Name'] = col
    value_counts_df = pd.concat([value_counts_df, value_counts], ignore_index=True)

# pie chart to display percentage of each class of features
fig, ax = plt.subplots(2, 3, figsize = (12, 8))
ax[0][0].pie(dataset['released'].value_counts().values, labels=dataset['released'].value_counts().index, autopct='%1.1f%%')
ax[0][0].set_title('released counts')
ax[0][1].pie(dataset['colour'].value_counts().values, labels=dataset['colour'].value_counts().index, autopct='%1.1f%%')
ax[0][1].set_title('colour counts')
ax[0][2].pie(dataset['sex'].value_counts().values, labels=dataset['sex'].value_counts().index, autopct='%1.1f%%')
ax[0][2].set_title('sex counts')
ax[1][0].pie(dataset['employed'].value_counts().values, labels=dataset['employed'].value_counts().index, autopct='%1.1f%%')
ax[1][0].set_title('employed counts')
ax[1][1].pie(dataset['citizen'].value_counts().values, labels=dataset['citizen'].value_counts().index, autopct='%1.1f%%')
ax[1][1].set_title('citizen counts')
ax[1][2].axis('off')
plt.suptitle('value counts of each category')
plt.show()

plt.close()

sns.histplot(data=dataset, x='age')
plt.show()
plt.close()