repl.it
@justinholman/

CompareSedans

Python

No description

fork
loading
Files
  • main.py
  • cmx.csv
  • compare-sedans.csv
  • scatter-a4.png
  • scatter-accord.png
  • scatter-fusion.png
  • scatter-impala.png
  • swarm1.png
  • swarm2.png
main.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
40
41
42
43
44
45
46
47
48
49
50
51
52
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
#import numpy as np
import seaborn as sns
mpl.use('Agg')

# read veh data
vehdata = pd.read_csv('compare-sedans.csv')

# swarmplots for Prevalence
sns.swarmplot(data=vehdata.ix[:,7:])
#plt.xlabel('Vehicles')
plt.ylabel('Prevalence by County')
plt.show()
plt.savefig('swarm1.png')
plt.clf()

# swarmplots for Population
sns.swarmplot(data=vehdata.ix[:,3:7])
#plt.xlabel('Vehicles')
plt.ylabel('Total Population by County')
plt.show()
plt.savefig('swarm2.png')
plt.clf()

# generate correlation matrix
nvars = vehdata.iloc[:,1:]
cmx = nvars.corr(method='pearson')
print(cmx)
cmx.to_csv('cmx.csv')

# scatterplots comparing rate with hhincome
sns.regplot('hhincome','accord-rate',data=vehdata)
plt.show()
plt.savefig('scatter-accord.png')
plt.clf()

sns.regplot('hhincome','a4-rate',data=vehdata)
plt.show()
plt.savefig('scatter-a4.png')
plt.clf()

sns.regplot('hhincome','impala-rate',data=vehdata)
plt.show()
plt.savefig('scatter-impala.png')
plt.clf()

sns.regplot('hhincome','fusion-rate',data=vehdata)
plt.show()
plt.savefig('scatter-fusion.png')
plt.clf()