回答編集履歴
2
修正
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
-
#
|
61
|
+
# 日付 - 週の最初から数えた日数 = 週の最初の日 (月曜=0の場合)
|
62
62
|
|
63
63
|
begin = first - pd.to_timedelta(first.dayofweek, unit="d")
|
64
64
|
|
@@ -68,7 +68,7 @@
|
|
68
68
|
|
69
69
|
# ビンを作成
|
70
70
|
|
71
|
-
weeks = pd.date_range(begin, end, freq="W-MON")
|
71
|
+
weeks = pd.date_range(begin.floor("D"), end.floor("D"), freq="W-MON")
|
72
72
|
|
73
73
|
# ビン分割処理
|
74
74
|
|
@@ -92,77 +92,79 @@
|
|
92
92
|
|
93
93
|
```
|
94
94
|
|
95
|
-
[2020-01-06
|
95
|
+
[2020-01-06, 2020-01-13) 2
|
96
96
|
|
97
|
-
[2020-01-13
|
97
|
+
[2020-01-13, 2020-01-20) 1
|
98
98
|
|
99
|
-
[2020-01-20
|
99
|
+
[2020-01-20, 2020-01-27) 1
|
100
100
|
|
101
|
-
[2020-01-27
|
101
|
+
[2020-01-27, 2020-02-03) 0
|
102
102
|
|
103
|
-
[2020-02-03
|
103
|
+
[2020-02-03, 2020-02-10) 1
|
104
104
|
|
105
|
-
[2020-02-10
|
105
|
+
[2020-02-10, 2020-02-17) 1
|
106
106
|
|
107
|
-
[2020-02-17
|
107
|
+
[2020-02-17, 2020-02-24) 0
|
108
108
|
|
109
|
-
[2020-02-24
|
109
|
+
[2020-02-24, 2020-03-02) 0
|
110
110
|
|
111
|
-
[2020-03-02
|
111
|
+
[2020-03-02, 2020-03-09) 1
|
112
112
|
|
113
|
-
[2020-03-09
|
113
|
+
[2020-03-09, 2020-03-16) 0
|
114
114
|
|
115
|
-
[2020-03-16
|
115
|
+
[2020-03-16, 2020-03-23) 0
|
116
116
|
|
117
|
-
[2020-03-23
|
117
|
+
[2020-03-23, 2020-03-30) 1
|
118
118
|
|
119
|
-
[2020-03-30
|
119
|
+
[2020-03-30, 2020-04-06) 0
|
120
120
|
|
121
|
-
[2020-04-06
|
121
|
+
[2020-04-06, 2020-04-13) 0
|
122
122
|
|
123
|
-
[2020-04-13
|
123
|
+
[2020-04-13, 2020-04-20) 1
|
124
124
|
|
125
|
-
[2020-04-20
|
125
|
+
[2020-04-20, 2020-04-27) 1
|
126
126
|
|
127
|
-
[2020-04-27
|
127
|
+
[2020-04-27, 2020-05-04) 0
|
128
128
|
|
129
|
-
[2020-05-04
|
129
|
+
[2020-05-04, 2020-05-11) 0
|
130
130
|
|
131
|
-
[2020-05-11
|
131
|
+
[2020-05-11, 2020-05-18) 0
|
132
132
|
|
133
|
-
[2020-05-18
|
133
|
+
[2020-05-18, 2020-05-25) 0
|
134
134
|
|
135
|
-
[2020-05-25
|
135
|
+
[2020-05-25, 2020-06-01) 0
|
136
136
|
|
137
|
-
[2020-06-01
|
137
|
+
[2020-06-01, 2020-06-08) 0
|
138
138
|
|
139
|
-
[2020-06-08
|
139
|
+
[2020-06-08, 2020-06-15) 0
|
140
140
|
|
141
|
-
[2020-06-15
|
141
|
+
[2020-06-15, 2020-06-22) 0
|
142
142
|
|
143
|
-
[2020-06-22
|
143
|
+
[2020-06-22, 2020-06-29) 0
|
144
144
|
|
145
|
-
[2020-06-29
|
145
|
+
[2020-06-29, 2020-07-06) 0
|
146
146
|
|
147
|
-
[2020-07-06
|
147
|
+
[2020-07-06, 2020-07-13) 0
|
148
148
|
|
149
|
-
[2020-07-13
|
149
|
+
[2020-07-13, 2020-07-20) 0
|
150
150
|
|
151
|
-
[2020-07-20
|
151
|
+
[2020-07-20, 2020-07-27) 0
|
152
152
|
|
153
|
-
[2020-07-27
|
153
|
+
[2020-07-27, 2020-08-03) 0
|
154
154
|
|
155
|
-
[2020-08-03
|
155
|
+
[2020-08-03, 2020-08-10) 0
|
156
156
|
|
157
|
-
[2020-08-10
|
157
|
+
[2020-08-10, 2020-08-17) 0
|
158
158
|
|
159
|
-
[2020-08-17
|
159
|
+
[2020-08-17, 2020-08-24) 0
|
160
160
|
|
161
|
-
[2020-08-24
|
161
|
+
[2020-08-24, 2020-08-31) 0
|
162
162
|
|
163
|
-
[2020-08-31
|
163
|
+
[2020-08-31, 2020-09-07) 0
|
164
164
|
|
165
|
-
[2020-09-07
|
165
|
+
[2020-09-07, 2020-09-14) 0
|
166
|
+
|
167
|
+
[2020-09-14, 2020-09-21) 0
|
166
168
|
|
167
169
|
dtype: int64
|
168
170
|
|
@@ -170,7 +172,7 @@
|
|
170
172
|
|
171
173
|
|
172
174
|
|
173
|
-
※ [2020-0
|
175
|
+
※ [2020-09-07, 2020-09-14) の場合、左半開区間なので、2020-09-07, 2020-09-13 を意味します。
|
174
176
|
|
175
177
|
|
176
178
|
|
1
修正
test
CHANGED
@@ -171,3 +171,9 @@
|
|
171
171
|
|
172
172
|
|
173
173
|
※ [2020-01-06 12:03:24, 2020-01-13 12:03:24) の場合、左半開区間なので、2020-01-06 ~ 2020-01-12 を意味します。
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
[pandas - 日時や期間の情報を取得する dt accessor の使い方](https://pystyle.info/pandas-dt-accessor/)
|
178
|
+
|
179
|
+
[pandas - cut、qcut でビン分割を行う方法](https://pystyle.info/pandas-how-to-binning/)
|