我有一个熊猫问题,尤其是在数据帧中按索引号移动
这是我的代码:
def wolumen(data, swieca):
list_of_volumen = []
for k in range(1, 30):
list_of_volumen.append(data['Volume'][swieca-k])
print(list_of_volumen)
candle = 0
hammer = 0
for i in data_frame.index:
candle+=1
if data_frame["Close"][i] < data_frame["Open"][i]:
body = 3 * (data_frame["Open"][i] - data_frame["Close"][i])
down_shadow = data_frame["Close"][i] - data_frame["Low"][i]
if body < down_shadow:
up_shadow = data_frame["High"][i] - data_frame["Open"][i]
if body > up_shadow:
hammer+=1
print("Hammer!!!")
print(data_frame.loc[i])
wolumen(data_frame, i)
我想用pandas和yfinance分析一些股票数据,我的数据框架如下:
| Open High Low Close Adj Close Volume
Datetime |
2020-01-10 09:00:00+01:00 | 9.950 10.075 9.900 10.030 10.030 767203
我无法将行的卷添加到此卷的列表中
完整错误如下所示:
Traceback (most recent call last):
File "aaa.py", line 45, in <module>
wolumen(data_frame, i)
File "aaa.py", line 28, in wolumen
list_of_volumen.append(data['Volume'][swieca-k])
File "pandas\_libs\tslibs\timestamps.pyx", line 343, in pandas._libs.tslibs.timestamps._Timestamp.__sub__
File "pandas\_libs\tslibs\timestamps.pyx", line 320, in pandas._libs.tslibs.timestamps._Timestamp.__add__
TypeError: Addition/subtraction of integers and integer-arrays with Timestamp is no longer supported. Instead of adding/subtracting `n`, use `n * obj.freq`
然后,您的操作方式是不可能的,因为您直接在_volumen.append(data['Volume'][swieca-k]的时间戳列表_上执行操作)
相关问题 更多 >
编程相关推荐