-
Notifications
You must be signed in to change notification settings - Fork 0
/
20evic_analysis.py
39 lines (35 loc) · 1.48 KB
/
20evic_analysis.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
39
import pandas as pd
import scipy
import numpy as np
import matplotlib.pyplot as plt
#dataf = pd.read_csv("eviction_with_census_tract.csv")
#plot2 = dataf['poly_typ'].value_counts().plot.bar()
#dataf['count'] = dataf.groupby('owner_name')['owner_name'].transform('count')
#dataf.dropna(subset=['count', 'owner_name'])
#filtered = dataf[dataf['count'] > 20]
#plot1 = filtered['court_divi'].value_counts().plot.bar(rot =0)
#plt.show()
#print(filtered.value_counts(subset = 'owner_name'))
#penelope fiaschetti's work (pennifer)
dataf = pd.read_csv("eviction_with_census_tract.csv")
#plot2 = dataf['Corp'].value_counts().plot.bar()
#plt.title('Eviction Filings')
#plt.xlabel('Owner is a corporation')
#plt.ylabel('Filing Count')
dataf['count'] = dataf.groupby('owner_name')['owner_name'].transform('count')
dataf.dropna(subset=['count', 'owner_name'])
filtered = dataf[dataf['count'] > 20]
#plot1 = filtered['Corp'].value_counts().plot.bar(rot =0)
#plt.title('Eviction Filings by Owners with more than 20 Filings')
#plt.xlabel('Owner is a corporation')
#plt.ylabel('Filing Count')
a = dataf[dataf.Corp == True]
b = dataf[dataf.Corp == False]
histdata = np.array([a['count'].tolist() ,b['count'].tolist()])
plt.hist(histdata, bins = 8, range = (0, 80), label = ['Corporation', 'Not Corporation'])
plt.legend()
plt.title('Eviction Filings Counts by Amount of filings by owner')
plt.xlabel('bins')
plt.ylabel('Count')
plt.show()
#print(filtered.value_counts(subset = 'owner_name'))