質問編集履歴

2

ご回答を受けて試したことの追記

2018/08/15 03:29

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -132,6 +132,70 @@
132
132
 
133
133
 
134
134
 
135
+ ### ご回答を受けて試したこと
136
+
137
+ ```python
138
+
139
+ weekly = df.set_index(1).resample("D").sum()
140
+
141
+ remove = weekly.loc['2017-12-31']
142
+
143
+ weekly.drop(remove.index)
144
+
145
+ ```
146
+
147
+
148
+
149
+ エラー文
150
+
151
+ ```
152
+
153
+ ---------------------------------------------------------------------------
154
+
155
+ ValueError Traceback (most recent call last)
156
+
157
+ <ipython-input-16-7fa422054348> in <module>()
158
+
159
+ 1 remove = weekly.loc['2017-12-31']
160
+
161
+ ----> 2 weekly.drop(remove.index)
162
+
163
+
164
+
165
+ ~/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pandas/core/generic.py in drop(self, labels, axis, level, inplace, errors)
166
+
167
+ 2159 new_axis = axis.drop(labels, level=level, errors=errors)
168
+
169
+ 2160 else:
170
+
171
+ -> 2161 new_axis = axis.drop(labels, errors=errors)
172
+
173
+ 2162 dropped = self.reindex(**{axis_name: new_axis})
174
+
175
+ 2163 try:
176
+
177
+
178
+
179
+ ~/.pyenv/versions/anaconda3-5.0.1/lib/python3.6/site-packages/pandas/core/indexes/base.py in drop(self, labels, errors)
180
+
181
+ 3622 if errors != 'ignore':
182
+
183
+ 3623 raise ValueError('labels %s not contained in axis' %
184
+
185
+ -> 3624 labels[mask])
186
+
187
+ 3625 indexer = indexer[~mask]
188
+
189
+ 3626 return self.delete(indexer)
190
+
191
+
192
+
193
+ ValueError: labels [ 4 10 13 14] not contained in axis
194
+
195
+ ```
196
+
197
+
198
+
135
199
  ### 補足情報(FW/ツールのバージョンなど)
136
200
 
137
201
 

1

weekly.head()で出力したものの追記

2018/08/15 03:29

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -108,7 +108,27 @@
108
108
 
109
109
  ```
110
110
 
111
+ ### weekly.head()で出力したもの
111
112
 
113
+ ```
114
+
115
+ 1
116
+
117
+ 2017-01-01 1000
118
+
119
+ 2017-01-08 3000
120
+
121
+ 2017-01-15 5000
122
+
123
+ 2017-01-22 2000
124
+
125
+ 2017-01-29 2000
126
+
127
+ ...
128
+
129
+ 2017-12-31 1000
130
+
131
+ ```
112
132
 
113
133
 
114
134