<jupyter_start><jupyter_text>2001 - 2010 INDIA FRAUD STATISTICSBuilt by <NAME>, <NAME>, <NAME>, <NAME>, <NAME>Guidance - Indranil Das, Technical Analyst, Webskitters AcademyIn Association with Webskitters AcademyHooghly Engineering & Technology CollegeDownload Dataset Dependency - Click hereContents[Data Collection](division_ID1) | [Data Preprocessing](division_ID2) | [Data Visualization](division_ID3) Data Collection[MENU](division_ID0)<jupyter_code># import dataset from local repository
import pandas as pd
df = pd.read_csv('serious_fraud.csv')
df<jupyter_output><empty_output><jupyter_text>Data Preprocessing[MENU](division_ID0)<jupyter_code># check null values in the dataset
df.isnull().sum()
# fill the null values with 0
df.fillna(0, inplace = True)
# drop unneccesary columns
df.drop(['Group_Name', 'Sub_Group_Name'], axis = 1, inplace = True)
# change datatypes to int
df.iloc[:, -5] = df.iloc[:, -5].astype(int)
df.iloc[:, -4] = df.iloc[:, -4].astype(int)
df.iloc[:, -3] = df.iloc[:, -3].astype(int)
df.iloc[:, -2] = df.iloc[:, -2].astype(int)
df.iloc[:, -1] = df.iloc[:, -1].astype(int)<jupyter_output><empty_output><jupyter_text>Data Visualization[MENU](division_ID0) - 2001 - 2010 Total Fraud Comparison Statewise<jupyter_code>import matplotlib.pyplot as plt 
import seaborn as sns
import numpy as np
area = df.iloc[:, 0].unique()
cat1 = []
cat2 = []
cat3 = []
cat4 = []
cat5 = []
r = np.arange(len(area))
w = 0.2
for i in area:
    new = df[df.iloc[:, 0] == i].copy()
    cat1.append(new.iloc[:, -5].sum())
    cat2.append(new.iloc[:, -4].sum())
    cat3.append(new.iloc[:, -3].sum())
    cat4.append(new.iloc[:, -2].sum())
    cat5.append(new.iloc[:, -1].sum())
plt.figure(figsize = (16, 9))
plt.bar(r, cat1, alpha = .7)
plt.bar(r+w, cat2, alpha = .7)
plt.bar(r+w*2, cat3, alpha = .7)
plt.bar(r+w*3, cat4, alpha = .7)
plt.bar(r+w*4, cat5, alpha = .7)
plt.xticks(r, area, rotation = 90)
plt.legend(['1-10 Crores', '10-25 Crores', '25-50 Crores', '50-100 Crores', '>100 Crores'], loc = 'best')
plt.title('2001 - 2010 Total Fraud Comparison Statewise', bbox = {'facecolor': '0.8', 'pad': 5}, loc = 'center')
plt.show()<jupyter_output><empty_output><jupyter_text>- 2001 - 2010 Yearwise Fraud Comparison Statewise<jupyter_code>def plot_details(state):
    timeline = df.iloc[:, 1].unique()
    new = df[df.iloc[:, 0] == state].copy()
    r = np.arange(len(timeline))
    w = 0.1
    cat1 = []
    cat2 = []
    cat3 = []
    cat4 = []
    cat5 = []
    for i in timeline:
        new1 = new[new.iloc[:, 1] == i].copy()
        cat1.append(new1.iloc[:, -5].sum())
        cat2.append(new1.iloc[:, -4].sum())
        cat3.append(new1.iloc[:, -3].sum())
        cat4.append(new1.iloc[:, -2].sum())
        cat5.append(new1.iloc[:, -1].sum())
    if (sum(cat1) + sum(cat2) + sum(cat3) + sum(cat4) + sum(cat5)) == 0:
        return
    plt.figure(figsize = (16, 9))
    plt.bar(r, cat1, alpha = .7, width = w)
    plt.bar(r+w, cat2, alpha = .7, width = w)
    plt.bar(r+w*2, cat3, alpha = .7, width = w)
    plt.bar(r+w*3, cat4, alpha = .7, width = w)
    plt.bar(r+w*4, cat5, alpha = .7, width = w)
    plt.xticks(r+w*2, timeline, rotation = 90)
    plt.legend(['1-10 Crores', '10-25 Crores', '25-50 Crores', '50-100 Crores', '>100 Crores'], loc = 'best')
    plt.title(state + ' 2001 - 2010 Yearwise Fraud Statistics', bbox = {'facecolor': '0.8', 'pad': 5}, loc = 'center')
    plt.show()
for i in area:
    plot_details(i)<jupyter_output><empty_output><jupyter_text>- 2001 - 2010 Frequency of Frauds and Its Categories<jupyter_code>import random
cat_freq = []
for i in range(2, len(list(df.columns))):
    cat_freq.append(df.iloc[:, i].sum())
colors = ['teal', 'maroon', 'royalblue', 'crimson', 'lawngreen']
plt.figure(figsize = (8, 8))
plt.title('2001-2010 Frequency of Frauds and Its Categories', bbox={'facecolor':'0.8', 'pad':10}, loc = 'center')
plt.pie(cat_freq, colors = colors)
my_circle=plt.Circle((0,0), 0.7, color='white')
p=plt.gcf()
p.gca().add_artist(my_circle)
plt.legend(['1-10 Crores', '10-25 Crores', '25-50 Crores', '50-100 Crores', '>100 Crores'], loc = 'upper right', bbox_to_anchor = (-0.1, 1.), fontsize=20)
plt.show()<jupyter_output><empty_output><jupyter_text>- 2001 - 2010 Frequency of Frauds Statewise<jupyter_code>freq = []
for i in area:
    f = df[df.iloc[:, 0] == i].iloc[:, -5].sum()
    freq.append(f)
import geopandas as gpd
df = pd.DataFrame(list(zip(area, freq)), columns = ['Area_Name', 'Frequency'])
map_file = gpd.read_file('Indian_States.shp')
merged = map_file.set_index('st_nm').join(df.set_index('Area_Name'))
na = ['Andaman & Nicobar Island', 'Arunanchal Pradesh', 'Dadara & Nagar Havelli', 
      'NCT of Delhi', 'Telangana', 'Rajasthan', 'Lakshadweep']
val = [1, 0, 8, 200, 0, 0, 0]
j = 0
for i in na:
    merged.at[i, list(merged.columns)[1]] = val[j]
    j += 1
merged.iloc[:, -1] = merged.iloc[:, -1].astype(int)
fig, ax = plt.subplots(1, figsize=(16, 16))
ax.axis('off')
ax.set_title('2001 - 2010 Statewise Autotheft Stolen', bbox={'facecolor':'0.8', 'pad':5}, loc = 'center')
fig = merged.plot(column='Frequency', cmap='flare', linewidth=0.5, ax=ax, edgecolor='0.1',legend=True)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20069605568445475, 'fraction_numerical': 0.05529775715390565, 'mean_word_length': 4.3440082644628095, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '536937', 'license': 'MIT', 'n_tokens_mistral': 2256, 'n_tokens_neox': 2080, 'n_words': 467, 'path': 'Project Indian Crime Analysis/SERIOUS_FRAUD_STATS_INDIA.ipynb', 'repo_name': 'aroyofficial/PROJECT-GTP', 'size': '5201'}