<jupyter_start><jupyter_text>Importing Libraries<jupyter_code>import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import math<jupyter_output><empty_output><jupyter_text>Getting the data<jupyter_code>data = pd.read_csv('fatal-police-shootings-data.csv')
data.info()
data.head()<jupyter_output><empty_output><jupyter_text>Looking for missing data in the dataset<jupyter_code>miss_data = data.isna().sum()*100/data.shape[0]
miss_data
data.dropna(inplace=True)<jupyter_output><empty_output><jupyter_text>Looking for unique data within the set<jupyter_code>cardinality = {}
for col in data.columns:
    cardinality[col] = data[col].nunique()

cardinality
print("Race: ")
print(data['race'].unique())
print("Manner of death: ")
print(data['manner_of_death'].unique())
print("Threat Level: ") 
print(data['threat_level'].unique())
data['armed'].value_counts()
armed = data.groupby('armed')['armed'].agg('count').sort_values(ascending=True)
data['armed'] = data['armed'].apply(lambda x:'other' if x in armed[armed<=25] else x)
data['armed'].fillna('other',inplace = True)
data['armed'].unique()
data['armed'] = np.where((data.armed == 'undetermined'),'other',data.armed)
data['armed'].unique()
data['armed'] = np.where((data.armed == 'unknown weapon'),'other',data.armed)
data['armed'].unique()
data.age.median()
data.age.fillna(data.age.median(),inplace=True)
sns.distplot(data['age'])
sns.countplot(x='gender',hue='signs_of_mental_illness',data=data)
data['state'].unique()
plt.figure(figsize=(20,20))
sns.countplot(x='state',data=data)
sns.countplot(x='flee',hue='manner_of_death',data=data)
sns.countplot(x='race',hue='manner_of_death',data=data)
data["year"] = pd.to_datetime(data["date"]).dt.year
data.drop(columns='date',inplace=True)
sns.countplot(x='year',hue='manner_of_death',data=data)
fig,a = plt.subplots(1,2,figsize=(20,10))
sns.countplot(x='race',hue='threat_level',data=data,ax=a[0])
a[0].set_xlabel("Race vs Threat Level")
sns.countplot(x='race',hue='flee',data=data)
a[1].set_xlabel("Race vs Fleeing")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1944311089774364, 'fraction_numerical': 0.009121459433509362, 'mean_word_length': 10.45054945054945, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '516222', 'license': 'MIT', 'n_tokens_mistral': 820, 'n_tokens_neox': 788, 'n_words': 103, 'path': 'Police shootings-Kaggle.ipynb', 'repo_name': '7wikd/Police-Shootings-Kaggle', 'size': '2083'}