forked from RubensZimbres/Repo-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Date_Int
66 lines (61 loc) · 1.59 KB
/
Date_Int
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
import numpy as np
import pandas as pd
df = pd.DataFrame({"Date": ["2014-03-21","2014-03-22","2014-03-23","2014-03-24", "2014-03-25", "2014-03-26","2014-03-21","2014-03-22","2014-03-23","2014-03-24", "2014-03-25", "2014-03-26","2014-03-21","2014-03-22","2014-03-23","2014-03-24", "2014-03-25", "2014-03-26","2014-03-21","2014-03-22","2014-03-23","2014-03-24", "2014-03-25", "2014-03-26","2014-03-27","2014-03-28","2014-03-29", "2014-03-30", "2014-03-31"],
"X0":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1]})
y0 = np.array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1])
df["Date"] = pd.to_datetime(df["Date"]).dt.strftime("%Y%m%d")
print( df )
from imblearn.over_sampling import SMOTE
sm = SMOTE()
y0.shape
x, y = sm.fit_sample(np.array(df), np.array(y0))
pd.DataFrame(x).astype(dtype=int)
>>>
0 1
0 20140321 0
1 20140322 0
2 20140323 0
3 20140324 0
4 20140325 0
5 20140326 0
6 20140321 0
7 20140322 0
8 20140323 0
9 20140324 0
10 20140325 0
11 20140326 0
12 20140321 0
13 20140322 0
14 20140323 0
15 20140324 0
16 20140325 0
17 20140326 0
18 20140321 0
19 20140322 0
20 20140323 0
21 20140324 0
22 20140325 0
23 20140326 1
24 20140327 1
25 20140328 1
26 20140329 1
27 20140330 1
28 20140331 1
29 20140330 1
30 20140326 1
31 20140326 1
32 20140327 1
33 20140329 1
34 20140328 1
35 20140330 1
36 20140328 1
37 20140327 1
38 20140328 1
39 20140329 1
40 20140327 1
41 20140328 1
42 20140328 1
43 20140329 1
44 20140327 1
45 20140329 1
pd.to_datetime(df.iloc[:,0])