質問編集履歴
3
再編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -122,6 +122,12 @@
|
|
122
122
|
|
123
123
|
やはりAの列でobjectが表示されてしまいます。
|
124
124
|
|
125
|
+
(無料ダウンロードのデータだと効率よく使用できないようになっている、、?
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
---
|
130
|
+
|
125
131
|
|
126
132
|
|
127
133
|
```python
|
2
私的頂いた内容に沿っての修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -38,10 +38,94 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
+
---
|
42
|
+
|
43
|
+
以下、ppaulさんに回答頂いた内容について実践してみた内容となります。
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
どこかに数字ではないデータが入っている可能性があるということで、
|
48
|
+
|
49
|
+
ppaulさんに私的頂いたdtypeにてデータ型の確認を行ったところ、
|
50
|
+
|
51
|
+
以下のような結果が得られました。
|
52
|
+
|
41
53
|
|
42
54
|
|
43
55
|
```python
|
44
56
|
|
57
|
+
print(dataM1['Open'].dtype)
|
58
|
+
|
59
|
+
print(dataM1['High'].dtype)
|
60
|
+
|
61
|
+
print(dataM1['Low'].dtype)
|
62
|
+
|
63
|
+
print(dataM1['Close'].dtype)
|
64
|
+
|
65
|
+
print(dataM1['A'].dtype)
|
66
|
+
|
67
|
+
print(dataM1['f'].dtype)
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
float64
|
72
|
+
|
73
|
+
float64
|
74
|
+
|
75
|
+
float64
|
76
|
+
|
77
|
+
float64
|
78
|
+
|
79
|
+
object
|
80
|
+
|
81
|
+
int64
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
この結果より、Aの列に数字でないデータが入っている可能性があるということで、
|
86
|
+
|
87
|
+
ヒストリカルデータを別のサイトから取得し、同様に実行してみました。
|
88
|
+
|
89
|
+
[参照データ](https://www.axiory.com/jp/how-to-install/mt4-historical-data)
|
90
|
+
|
91
|
+
以下dtypeでの実行結果です。
|
92
|
+
|
93
|
+
```python
|
94
|
+
|
95
|
+
print(dataM1['Open'].dtype)
|
96
|
+
|
97
|
+
print(dataM1['High'].dtype)
|
98
|
+
|
99
|
+
print(dataM1['Low'].dtype)
|
100
|
+
|
101
|
+
print(dataM1['Close'].dtype)
|
102
|
+
|
103
|
+
print(dataM1['A'].dtype)
|
104
|
+
|
105
|
+
print(dataM1['f'].dtype)
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
float64
|
110
|
+
|
111
|
+
float64
|
112
|
+
|
113
|
+
float64
|
114
|
+
|
115
|
+
float64
|
116
|
+
|
117
|
+
object
|
118
|
+
|
119
|
+
int64
|
120
|
+
|
121
|
+
```
|
122
|
+
|
123
|
+
やはりAの列でobjectが表示されてしまいます。
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
```python
|
128
|
+
|
45
129
|
#pandasとnumpyをインポート
|
46
130
|
|
47
131
|
import pandas as pd
|
1
CSVファイルを参照したURLのリンクと、エラー内容の全文を掲載させて頂きました。(エラー内容長文となってしまい、申し訳ありません。)よろしくお願い致します。
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,6 +34,8 @@
|
|
34
34
|
|
35
35
|
[参考ページ](https://qiita.com/kazama1209/items/98f63b624f3987ba3322)
|
36
36
|
|
37
|
+
[csvファイル参照](http://www.histdata.com)
|
38
|
+
|
37
39
|
|
38
40
|
|
39
41
|
|
@@ -102,4 +104,204 @@
|
|
102
104
|
|
103
105
|
12 ohlc_1h
|
104
106
|
|
107
|
+
|
108
|
+
|
109
|
+
<ipython-input-4-5bc21324f74e> in make_mtf_ohlc(dataM1, tf)
|
110
|
+
|
111
|
+
1 def make_mtf_ohlc(dataM1, tf):
|
112
|
+
|
113
|
+
----> 2 x = dataM1.resample(tf).ohlc()
|
114
|
+
|
115
|
+
3 O = x['Open']['open']
|
116
|
+
|
117
|
+
4 H = x['High']['high']
|
118
|
+
|
119
|
+
5 L = x['Low']['low']
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/resample.py in f(self, _method, *args, **kwargs)
|
124
|
+
|
125
|
+
863 def f(self, _method=method, *args, **kwargs):
|
126
|
+
|
127
|
+
864 nv.validate_resampler_func(_method, args, kwargs)
|
128
|
+
|
129
|
+
--> 865 return self._downsample(_method)
|
130
|
+
|
131
|
+
866 f.__doc__ = getattr(GroupBy, method).__doc__
|
132
|
+
|
133
|
+
867 setattr(Resampler, method, f)
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/resample.py in _downsample(self, how, **kwargs)
|
138
|
+
|
139
|
+
1018 # we want to call the actual grouper method here
|
140
|
+
|
141
|
+
1019 result = obj.groupby(
|
142
|
+
|
143
|
+
-> 1020 self.grouper, axis=self.axis).aggregate(how, **kwargs)
|
144
|
+
|
145
|
+
1021
|
146
|
+
|
147
|
+
1022 result = self._apply_loffset(result)
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in aggregate(self, arg, *args, **kwargs)
|
152
|
+
|
153
|
+
1313 @Appender(_shared_docs['aggregate'])
|
154
|
+
|
155
|
+
1314 def aggregate(self, arg, *args, **kwargs):
|
156
|
+
|
157
|
+
-> 1315 return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
|
158
|
+
|
159
|
+
1316
|
160
|
+
|
161
|
+
1317 agg = aggregate
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in aggregate(self, arg, *args, **kwargs)
|
166
|
+
|
167
|
+
184
|
168
|
+
|
169
|
+
185 _level = kwargs.pop('_level', None)
|
170
|
+
|
171
|
+
--> 186 result, how = self._aggregate(arg, _level=_level, *args, **kwargs)
|
172
|
+
|
173
|
+
187 if how is None:
|
174
|
+
|
175
|
+
188 return result
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/base.py in _aggregate(self, arg, *args, **kwargs)
|
180
|
+
|
181
|
+
354 if isinstance(arg, compat.string_types):
|
182
|
+
|
183
|
+
355 return self._try_aggregate_string_function(arg, *args,
|
184
|
+
|
185
|
+
--> 356 **kwargs), None
|
186
|
+
|
187
|
+
357
|
188
|
+
|
189
|
+
358 if isinstance(arg, dict):
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/base.py in _try_aggregate_string_function(self, arg, *args, **kwargs)
|
194
|
+
|
195
|
+
310 if f is not None:
|
196
|
+
|
197
|
+
311 if callable(f):
|
198
|
+
|
199
|
+
--> 312 return f(*args, **kwargs)
|
200
|
+
|
201
|
+
313
|
202
|
+
|
203
|
+
314 # people may try to aggregate on a non-callable attribute
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in ohlc(self)
|
208
|
+
|
209
|
+
1317
|
210
|
+
|
211
|
+
1318 return self._apply_to_column_groupbys(
|
212
|
+
|
213
|
+
-> 1319 lambda x: x._cython_agg_general('ohlc'))
|
214
|
+
|
215
|
+
1320
|
216
|
+
|
217
|
+
1321 @Appender(DataFrame.describe.__doc__)
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in _apply_to_column_groupbys(self, func)
|
222
|
+
|
223
|
+
1490 (func(col_groupby) for _, col_groupby
|
224
|
+
|
225
|
+
1491 in self._iterate_column_groupbys()),
|
226
|
+
|
227
|
+
-> 1492 keys=self._selected_obj.columns, axis=1)
|
228
|
+
|
229
|
+
1493
|
230
|
+
|
231
|
+
1494 def _fill(self, direction, limit=None):
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/reshape/concat.py in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, sort, copy)
|
236
|
+
|
237
|
+
226 keys=keys, levels=levels, names=names,
|
238
|
+
|
239
|
+
227 verify_integrity=verify_integrity,
|
240
|
+
|
241
|
+
--> 228 copy=copy, sort=sort)
|
242
|
+
|
243
|
+
229 return op.get_result()
|
244
|
+
|
245
|
+
230
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/reshape/concat.py in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy, sort)
|
250
|
+
|
251
|
+
257 objs = [objs[k] for k in keys]
|
252
|
+
|
253
|
+
258 else:
|
254
|
+
|
255
|
+
--> 259 objs = list(objs)
|
256
|
+
|
257
|
+
260
|
258
|
+
|
259
|
+
261 if len(objs) == 0:
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/generic.py in <genexpr>(.0)
|
264
|
+
|
265
|
+
1488 from pandas.core.reshape.concat import concat
|
266
|
+
|
267
|
+
1489 return concat(
|
268
|
+
|
269
|
+
-> 1490 (func(col_groupby) for _, col_groupby
|
270
|
+
|
271
|
+
1491 in self._iterate_column_groupbys()),
|
272
|
+
|
273
|
+
1492 keys=self._selected_obj.columns, axis=1)
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in <lambda>(x)
|
278
|
+
|
279
|
+
1317
|
280
|
+
|
281
|
+
1318 return self._apply_to_column_groupbys(
|
282
|
+
|
283
|
+
-> 1319 lambda x: x._cython_agg_general('ohlc'))
|
284
|
+
|
285
|
+
1320
|
286
|
+
|
287
|
+
1321 @Appender(DataFrame.describe.__doc__)
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
~/anaconda3/lib/python3.7/site-packages/pandas/core/groupby/groupby.py in _cython_agg_general(self, how, alt, numeric_only, min_count)
|
292
|
+
|
293
|
+
836
|
294
|
+
|
295
|
+
837 if len(output) == 0:
|
296
|
+
|
297
|
+
--> 838 raise DataError('No numeric types to aggregate')
|
298
|
+
|
299
|
+
839
|
300
|
+
|
301
|
+
840 return self._wrap_aggregated_output(output, names)
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
DataError: No numeric types to aggregate
|
306
|
+
|
105
307
|
```
|