回答編集履歴
1
表示失敗を修正
test
CHANGED
@@ -12,101 +12,101 @@
|
|
12
12
|
|
13
13
|
dates
|
14
14
|
|
15
|
-
2021-04-29
|
15
|
+
2021-04-29 0 0 0 0 0
|
16
16
|
|
17
17
|
2021-04-30 1 0 0 0 0
|
18
18
|
|
19
|
-
2021-05-01
|
20
|
-
|
21
|
-
2021-05-02
|
22
|
-
|
23
|
-
2021-05-03
|
24
|
-
|
25
|
-
2021-05-04 0 0
|
26
|
-
|
27
|
-
2021-05-05
|
28
|
-
|
29
|
-
2021-05-06
|
30
|
-
|
31
|
-
2021-05-07
|
32
|
-
|
33
|
-
2021-05-08 0
|
34
|
-
|
35
|
-
2021-05-11 0
|
36
|
-
|
37
|
-
2021-05-12
|
38
|
-
|
39
|
-
2021-05-13
|
40
|
-
|
41
|
-
2021-05-14
|
42
|
-
|
43
|
-
2021-05-15
|
44
|
-
|
45
|
-
2021-05-16
|
46
|
-
|
47
|
-
2021-05-17
|
48
|
-
|
49
|
-
2021-05-18 1 0
|
50
|
-
|
51
|
-
2021-05-19 0 1
|
52
|
-
|
53
|
-
2021-05-20
|
54
|
-
|
55
|
-
2021-05-21
|
56
|
-
|
57
|
-
2021-05-22 0
|
58
|
-
|
59
|
-
2021-05-23
|
60
|
-
|
61
|
-
2021-05-24
|
62
|
-
|
63
|
-
2021-05-25
|
64
|
-
|
65
|
-
2021-05-26
|
66
|
-
|
67
|
-
2021-05-27 1
|
68
|
-
|
69
|
-
2021-05-28
|
70
|
-
|
71
|
-
2021-05-29 0
|
72
|
-
|
73
|
-
2021-05-30 1 0 1
|
74
|
-
|
75
|
-
2021-05-31 0
|
76
|
-
|
77
|
-
2021-06-01 0
|
78
|
-
|
79
|
-
2021-06-02 1 1 0
|
80
|
-
|
81
|
-
2021-06-03
|
82
|
-
|
83
|
-
2021-06-04 0
|
84
|
-
|
85
|
-
2021-05-12
|
86
|
-
|
87
|
-
2021-05-13
|
88
|
-
|
89
|
-
2021-05-14
|
90
|
-
|
91
|
-
2021-05-15
|
92
|
-
|
93
|
-
2021-05-16
|
94
|
-
|
95
|
-
2021-05-17
|
96
|
-
|
97
|
-
2021-05-18 1 0
|
98
|
-
|
99
|
-
2021-05-19 0 1
|
100
|
-
|
101
|
-
2021-05-20
|
102
|
-
|
103
|
-
2021-05-21
|
104
|
-
|
105
|
-
2021-05-22 0
|
106
|
-
|
107
|
-
2021-05-23
|
108
|
-
|
109
|
-
2021-05-24
|
19
|
+
2021-05-01 1 0 0 0 1
|
20
|
+
|
21
|
+
2021-05-02 0 0 0 0 0
|
22
|
+
|
23
|
+
2021-05-03 1 0 0 2 0
|
24
|
+
|
25
|
+
2021-05-04 0 0 0 0 0
|
26
|
+
|
27
|
+
2021-05-05 1 0 0 0 1
|
28
|
+
|
29
|
+
2021-05-06 2 0 1 0 0
|
30
|
+
|
31
|
+
2021-05-07 0 0 0 0 0
|
32
|
+
|
33
|
+
2021-05-08 0 1 0 0 0
|
34
|
+
|
35
|
+
2021-05-11 0 3 1 1 1
|
36
|
+
|
37
|
+
2021-05-12 1 1 1 0 2
|
38
|
+
|
39
|
+
2021-05-13 0 0 1 0 0
|
40
|
+
|
41
|
+
2021-05-14 1 0 0 1 2
|
42
|
+
|
43
|
+
2021-05-15 3 1 1 3 0
|
44
|
+
|
45
|
+
2021-05-16 0 2 0 0 0
|
46
|
+
|
47
|
+
2021-05-17 0 1 0 2 0
|
48
|
+
|
49
|
+
2021-05-18 1 0 2 2 3
|
50
|
+
|
51
|
+
2021-05-19 0 1 0 0 0
|
52
|
+
|
53
|
+
2021-05-20 2 2 0 0 2
|
54
|
+
|
55
|
+
2021-05-21 0 0 0 0 0
|
56
|
+
|
57
|
+
2021-05-22 0 2 2 2 0
|
58
|
+
|
59
|
+
2021-05-23 0 0 1 2 1
|
60
|
+
|
61
|
+
2021-05-24 0 0 1 0 1
|
62
|
+
|
63
|
+
2021-05-25 0 0 0 1 1
|
64
|
+
|
65
|
+
2021-05-26 1 0 0 0 1
|
66
|
+
|
67
|
+
2021-05-27 1 0 1 0 0
|
68
|
+
|
69
|
+
2021-05-28 1 0 0 0 0
|
70
|
+
|
71
|
+
2021-05-29 0 1 0 0 0
|
72
|
+
|
73
|
+
2021-05-30 1 0 1 0 0
|
74
|
+
|
75
|
+
2021-05-31 0 2 0 0 0
|
76
|
+
|
77
|
+
2021-06-01 0 1 1 1 1
|
78
|
+
|
79
|
+
2021-06-02 1 1 0 2 0
|
80
|
+
|
81
|
+
2021-06-03 0 0 1 1 1
|
82
|
+
|
83
|
+
2021-06-04 0 2 0 0 1
|
84
|
+
|
85
|
+
2021-05-12 1 1 1 0 2
|
86
|
+
|
87
|
+
2021-05-13 0 0 1 0 0
|
88
|
+
|
89
|
+
2021-05-14 1 0 0 1 2
|
90
|
+
|
91
|
+
2021-05-15 3 1 1 3 0
|
92
|
+
|
93
|
+
2021-05-16 0 2 0 0 0
|
94
|
+
|
95
|
+
2021-05-17 0 1 0 2 0
|
96
|
+
|
97
|
+
2021-05-18 1 0 2 2 3
|
98
|
+
|
99
|
+
2021-05-19 0 1 0 0 0
|
100
|
+
|
101
|
+
2021-05-20 2 2 0 0 2
|
102
|
+
|
103
|
+
2021-05-21 0 0 0 0 0
|
104
|
+
|
105
|
+
2021-05-22 0 2 2 2 0
|
106
|
+
|
107
|
+
2021-05-23 0 0 1 2 1
|
108
|
+
|
109
|
+
2021-05-24 0 0 1 0 1
|
110
110
|
|
111
111
|
```
|
112
112
|
|
@@ -116,92 +116,110 @@
|
|
116
116
|
|
117
117
|
>>> print(dates)
|
118
118
|
|
119
|
+
>>> print(dates)
|
120
|
+
|
119
121
|
['2021-04-29', '2021-04-30', '2021-05-01', '2021-05-02', '2021-05-03', '2021-05-04', '2021-05-05', '2021-05-06', '2021-05-07', '2021-05-08', '2021-05-11', '2021-05-12', '2021-05-13', '2021-05-14', '2021-05-15', '2021-05-16', '2021-05-17', '2021-05-18', '2021-05-19', '2021-05-20', '2021-05-21', '2021-05-22', '2021-05-23', '2021-05-24', '2021-05-25', '2021-05-26', '2021-05-27', '2021-05-28', '2021-05-29', '2021-05-30', '2021-05-31', '2021-06-01', '2021-06-02', '2021-06-03', '2021-06-04', '2021-05-12', '2021-05-13', '2021-05-14', '2021-05-15', '2021-05-16', '2021-05-17', '2021-05-18', '2021-05-19', '2021-05-20', '2021-05-21', '2021-05-22', '2021-05-23', '2021-05-24']
|
120
122
|
|
121
123
|
>>> print(df)
|
122
124
|
|
123
125
|
push1_start_date push2_start_date push3_start_date push4_start_date push5_start_date
|
124
126
|
|
125
|
-
0
|
126
|
-
|
127
|
-
1 2021-05-2
|
128
|
-
|
129
|
-
2
|
130
|
-
|
131
|
-
3 <NA>
|
132
|
-
|
133
|
-
4 2021-05-1
|
134
|
-
|
135
|
-
5 <NA> 2021-05-2
|
136
|
-
|
137
|
-
6 2021-05-
|
138
|
-
|
139
|
-
7 <NA>
|
140
|
-
|
141
|
-
8 2021-05-
|
142
|
-
|
143
|
-
9 2021-0
|
144
|
-
|
145
|
-
10 <NA>
|
146
|
-
|
147
|
-
11
|
148
|
-
|
149
|
-
12
|
150
|
-
|
151
|
-
13 <NA>
|
152
|
-
|
153
|
-
14 2021-05-2
|
154
|
-
|
155
|
-
15
|
156
|
-
|
157
|
-
16 2021-05-1
|
158
|
-
|
159
|
-
17 2021-05-03 2021-05-0
|
160
|
-
|
161
|
-
18
|
162
|
-
|
163
|
-
19 2021-0
|
164
|
-
|
165
|
-
20 2021-05-
|
166
|
-
|
167
|
-
21
|
168
|
-
|
169
|
-
22 2021-05-0
|
170
|
-
|
171
|
-
23 2021-0
|
172
|
-
|
173
|
-
24 2021-05-
|
174
|
-
|
175
|
-
25 2021-0
|
176
|
-
|
177
|
-
26 2021-0
|
178
|
-
|
179
|
-
27 2021-05-2
|
180
|
-
|
181
|
-
28
|
182
|
-
|
183
|
-
29 2021-05-
|
184
|
-
|
185
|
-
30 2021-05-18 2021-05-16 2021-05-08 <NA> 2021-05-28
|
186
|
-
|
187
|
-
31 2021-05-15 2021-05-14 <NA> 2021-05-30 <NA>
|
188
|
-
|
189
|
-
32 2021-05-17 2021-05-21 2021-05-22 <NA> 2021-05-13
|
190
|
-
|
191
|
-
33 2021-05-14 2021-05-11 2021-06-01 2021-05-20 2021-05-24
|
192
|
-
|
193
|
-
34 2021-05-23 <NA> 2021-05-24 2021-06-03 2021-05-04
|
194
|
-
|
195
|
-
35 <NA> <NA> 2021-05-06 2021-05-24 2021-05-23
|
196
|
-
|
197
|
-
36 <NA> <NA> <NA> 2021-05-25 <NA>
|
198
|
-
|
199
|
-
37 2021-05-03 2021-05-13 2021-05-06 2021-05-17 <NA>
|
200
|
-
|
201
|
-
38 2021-06-03 2021-04-29 2021-05-21 <NA> 2021-05-07
|
202
|
-
|
203
|
-
39 2021-05-25 2021-05-16 2021-05-15 2021-05-16 <NA>
|
127
|
+
0 <NA> 2021-06-02 2021-05-06 <NA> 2021-05-20
|
128
|
+
|
129
|
+
1 2021-05-26 <NA> <NA> 2021-05-14 <NA>
|
130
|
+
|
131
|
+
2 <NA> 2021-05-16 <NA> 2021-05-15 2021-05-01
|
132
|
+
|
133
|
+
3 <NA> <NA> 2021-06-03 2021-05-03 <NA>
|
134
|
+
|
135
|
+
4 2021-05-18 2021-05-11 2021-05-12 2021-05-11 2021-05-23
|
136
|
+
|
137
|
+
5 <NA> 2021-05-22 <NA> 2021-05-17 2021-05-18
|
138
|
+
|
139
|
+
6 2021-05-06 <NA> 2021-05-15 <NA> <NA>
|
140
|
+
|
141
|
+
7 <NA> <NA> <NA> <NA> 2021-05-11
|
142
|
+
|
143
|
+
8 2021-05-30 2021-06-04 2021-05-18 2021-06-02 2021-05-18
|
144
|
+
|
145
|
+
9 2021-05-01 2021-05-16 <NA> 2021-05-25 2021-05-14
|
146
|
+
|
147
|
+
10 2021-05-12 <NA> <NA> <NA> 2021-05-24
|
148
|
+
|
149
|
+
11 2021-05-06 2021-05-17 2021-05-24 2021-05-23 2021-05-18
|
150
|
+
|
151
|
+
12 <NA> <NA> 2021-06-01 2021-05-18 2021-06-03
|
152
|
+
|
153
|
+
13 <NA> 2021-05-11 <NA> 2021-06-02 2021-05-14
|
154
|
+
|
155
|
+
14 2021-05-28 2021-06-01 2021-05-11 <NA> 2021-06-01
|
156
|
+
|
157
|
+
15 <NA> 2021-05-11 <NA> 2021-05-17 <NA>
|
158
|
+
|
159
|
+
16 2021-05-15 2021-05-15 <NA> <NA> 2021-06-04
|
160
|
+
|
161
|
+
17 2021-05-14 2021-05-31 2021-05-30 <NA> <NA>
|
162
|
+
|
163
|
+
18 2021-04-30 2021-05-08 <NA> 2021-05-03 2021-05-26
|
164
|
+
|
165
|
+
19 2021-05-20 <NA> 2021-05-23 2021-05-15 <NA>
|
166
|
+
|
167
|
+
20 <NA> 2021-05-29 2021-05-27 2021-05-15 2021-05-05
|
168
|
+
|
169
|
+
21 <NA> 2021-05-22 <NA> <NA> 2021-05-12
|
170
|
+
|
171
|
+
22 2021-05-20 2021-05-20 <NA> 2021-06-01 2021-05-25
|
172
|
+
|
173
|
+
23 <NA> 2021-05-31 <NA> 2021-05-18 <NA>
|
174
|
+
|
175
|
+
24 2021-05-05 2021-06-04 2021-05-22 2021-05-22 <NA>
|
176
|
+
|
177
|
+
25 2021-05-03 2021-05-20 2021-05-18 <NA> <NA>
|
178
|
+
|
179
|
+
26 2021-06-02 2021-05-12 <NA> 2021-05-22 2021-05-20
|
180
|
+
|
181
|
+
27 2021-05-27 <NA> 2021-05-13 2021-06-03 <NA>
|
182
|
+
|
183
|
+
28 2021-05-15 2021-05-19 <NA> <NA> <NA>
|
184
|
+
|
185
|
+
29 2021-05-15 <NA> 2021-05-22 2021-05-23 2021-05-12
|
204
186
|
|
205
187
|
```
|
206
188
|
|
207
189
|
処理
|
190
|
+
|
191
|
+
```python
|
192
|
+
|
193
|
+
df_dates = pd.DataFrame({'dates': dates})
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
def count_one_column(df, column, df_dates):
|
198
|
+
|
199
|
+
df1 = df[[column]].copy()
|
200
|
+
|
201
|
+
df1['count'] = 1
|
202
|
+
|
203
|
+
df2 = df1.groupby(column).sum().reset_index()
|
204
|
+
|
205
|
+
df3 = pd.merge(df_dates, df2,
|
206
|
+
|
207
|
+
left_on='dates', right_on=column, how='left')
|
208
|
+
|
209
|
+
df4 = df3.drop(column, axis=1).set_index('dates')
|
210
|
+
|
211
|
+
df4.columns = [column]
|
212
|
+
|
213
|
+
df4.fillna(0.0, inplace=True)
|
214
|
+
|
215
|
+
df5 = df4[column].astype(int)
|
216
|
+
|
217
|
+
return df5
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
df_counts = pd.concat([count_one_column(df, column, df_dates) for column in df.columns], axis=1)
|
222
|
+
|
223
|
+
print(df_counts)
|
224
|
+
|
225
|
+
```
|