回答編集履歴
1
コード修正
test
CHANGED
@@ -18,9 +18,11 @@
|
|
18
18
|
|
19
19
|
import datetime
|
20
20
|
|
21
|
+
import calendar
|
21
22
|
|
22
23
|
|
24
|
+
|
23
|
-
df = pd.DataFrame({'Time':['2018-02-02 05:00:00', '2018-02-28 05:00:00','2018-03-31 05:00:00','201
|
25
|
+
df = pd.DataFrame({'Time':['2018-02-02 05:00:00', '2018-02-28 05:00:00','2018-03-31 05:00:00','2018-04-30 05:00:00','2018-12-31 05:00:00']})
|
24
26
|
|
25
27
|
df['Time'] = pd.to_datetime(df['Time'])
|
26
28
|
|
@@ -32,7 +34,13 @@
|
|
32
34
|
|
33
35
|
d_cur = dt.date()
|
34
36
|
|
37
|
+
|
38
|
+
|
39
|
+
y,m = d_cur.year,d_cur.month
|
40
|
+
|
41
|
+
ym = calendar.monthrange(y, m)
|
42
|
+
|
35
|
-
d_last = datetime.date(
|
43
|
+
d_last = datetime.date(y, m, ym[1]) # 月末
|
36
44
|
|
37
45
|
|
38
46
|
|
@@ -64,14 +72,20 @@
|
|
64
72
|
|
65
73
|
print(df)
|
66
74
|
|
67
|
-
|
75
|
+
"""
|
68
76
|
|
69
|
-
|
77
|
+
Time Weekdays EOM
|
70
78
|
|
71
|
-
|
79
|
+
0 2018-02-02 05:00:00 Friday 0
|
72
80
|
|
73
|
-
|
81
|
+
1 2018-02-28 05:00:00 Wednesday 1
|
74
82
|
|
83
|
+
2 2018-03-31 05:00:00 Saturday 0
|
84
|
+
|
75
|
-
|
85
|
+
3 2018-04-30 05:00:00 Monday 0
|
86
|
+
|
87
|
+
4 2018-12-31 05:00:00 Monday 1
|
88
|
+
|
89
|
+
"""
|
76
90
|
|
77
91
|
```
|