-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotter.py
80 lines (45 loc) · 1.92 KB
/
plotter.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from pandas import DataFrame
from plotly.utils import pandas
from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import spline
import pandas as pd
dataset = pandas.read_csv('04:36PM on July 19, 2018.csv', engine='python')
old_data = pandas.read_csv('07:24PM on July 18, 2018.csv', engine='python', skipfooter=3)
scaler = MinMaxScaler(feature_range=(0, 1))
#dataset['total_cases'] = scaler.fit_transform(dataset['total_cases'])
def split_dataset_by_city(df):
return df[df['city'] == 'iq'], df[df['city'] == 'sj']
print (dataset)
#////////////////////////////////////////////////////////////for san juan
iq, sj = split_dataset_by_city(dataset)
iq_old, sj_old = split_dataset_by_city(old_data)
T = np.array(sj.index)
power = np.array(sj['total_cases'])
xnew = np.linspace(T.min(),T.max(),20)
power_smooth = spline(T,power,xnew)
xnew_new = np.linspace(xnew.min(), xnew.max(), 260)
power_smooth_new = spline(xnew,power_smooth,xnew_new)
power_smooth_new = power_smooth_new.astype(int)
df_bbbb = DataFrame(power_smooth_new)
#df_bbbb = df_bbbb.clip(lower=0)
plt.plot(xnew_new,power_smooth_new)
#////////////////////////////////////////////////////
T = np.array(iq.index)
power = np.array(iq['total_cases'])
xnew = np.linspace(T.min(),T.max(),12)
power_smooth = spline(T,power,xnew)
xnew_new = np.linspace(xnew.min(), xnew.max(),156 )
power_smooth_new = spline(xnew,power_smooth,xnew_new)
power_smooth_new = power_smooth_new.astype(int)
df_bb = pd.concat([df_bbbb, DataFrame(power_smooth_new)])
df_bb = df_bb.reset_index(drop=True)
df_bb = df_bb.clip(lower=0)
dataset['total_cases'] = df_bb[0].values
#dataset[dataset['city'] == 'sj']['total_cases'].assign(df_bbbb[0])
#dataset.replace(dataset[dataset['city'] == 'sj']['total_cases'], df_bbbb[0])
#plt.plot(sj_old['total_cases'])
dataset.to_csv("sub_t.csv",index=False)
#plt.plot(xnew_new,power_smooth_new)
plt.show()