-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrime Data Visualization by LineChart.py
38 lines (38 loc) · 1.28 KB
/
Crime Data Visualization by LineChart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
df = pd.read_csv('project_file.csv')
df.head()
df = df.sample(frac=0.5, replace=True, random_state=1)
df_murder_sorted = df.sort_values(by=['murder'])
df_rape_sorted = df.sort_values(by=['rape'])
df_robbery_sorted = df.sort_values(by=['robbery'])
df_theft_sorted = df.sort_values(by=['theft'])
df_riots_sorted = df.sort_values(by=['riots'])
df_cheating_sorted = df.sort_values(by=['cheating'])
df_dd_sorted = df.sort_values(by=['dowry_deaths'])
df_year_sorted = df.sort_values(by=['year'])
plt.plot(df_murder_sorted['murder'],df_rape_sorted['rape'] * 100)
plt.xlabel('Murder')
plt.ylabel('Rape')
plt.show()
plt.plot(df_murder_sorted['murder'],df_robbery_sorted['robbery'] * 100)
plt.xlabel('Murder')
plt.ylabel('Robbery')
plt.show()
plt.plot(df_murder_sorted['murder'],df_theft_sorted['theft'] * 100)
plt.xlabel('Murder')
plt.ylabel('theft')
plt.show()
plt.plot(df_murder_sorted['murder'],df_riots_sorted['riots'] * 100)
plt.xlabel('Murder')
plt.ylabel('Riots')
plt.show()
plt.plot(df_murder_sorted['murder'],df_cheating_sorted['cheating'] * 100)
plt.xlabel('Murder')
plt.ylabel('Cheating')
plt.show()
plt.plot(df_murder_sorted['murder'],df_dd_sorted['dowry_deaths'] * 100)
plt.xlabel('Murder')
plt.ylabel('Dowry Deaths')
plt.show()