forked from gzavo/CS_Assignment_old
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrelation.py
More file actions
24 lines (19 loc) · 764 Bytes
/
Copy pathcorrelation.py
File metadata and controls
24 lines (19 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import DefaultDict
import pandas as pd
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['figure.dpi'] = 300
# get a dataframe
df_raw = pd.read_csv('istherecorrelation.csv',sep=';', decimal=",")
df = df_raw.rename(columns={'WO [x1000]': 'students', 'NL Beer consumption [x1000 hectoliter]': 'beer'})
# calculate hectoliters of beer per 1000 students
ratio = df["beer"]/df['students']
df["ratio"] = ratio
df.plot.scatter(x='students', y='beer')
plt.xlabel('Number of students (x1000)'); plt.ylabel('Beer consumption (x1000 hectoliter)')
plt.savefig('absolute.png')
plt.show()
df.plot.scatter(x='Year', y='ratio')
plt.xlabel('Year'); plt.ylabel('Ratio beer/students (hectoliter per student)')
plt.savefig('ratio.png')
plt.show()