我无法将一个 numpy 数组从一个 numpy 数组的元组分配给一个 pandas 数据框。有人能帮我吗?我正在使用第三方库来获取数据并生成输出 numpy 数组。
代码:
import time
import numpy as np
import pandas as pd
import ccxt # crypto exchange library
import tulipy as ti # financial indicators
def currentTimeMillis(self):
return int(round(time.time() * 1000))
currentMillisMinus250min = currentTimeMillis() - 30000000
bitmex = ccxt.bitmex()
ohlcvDf = pd.DataFrame(
bitmex.fetch_ohlcv(symbol="BTC/USD", limit=500, timeframe="1m", since=currentMillisMinus250min),
columns = ["timestamp", "open", "high", "low", "close", "volume"])
macdNp = ti.macd(ohlcvDf["close"].to_numpy(), 12, 26, 9)
ohlcvDf["macd"] = macdNp[0]
ohlcvDf["signal"] = macdNp[1]
错误:
ValueError: Length of values does not match length of index
字符元组:
(
array([ 6.68695914e+00, 6.12108219e+00, 5.64479926e+00, 4.94431782e+00,
4.33794071e+00, 3.81237487e+00, 3.46875952e+00, 3.15956840e+00]),
array([ 6.68695914, 6.57378375, 6.38798685, 6.09925304,
5.74699058, 5.36006744, 4.98180585, 4.61735836]),
array([ 0.00000000e+00, -4.52701560e-01, -7.43187590e-01, -1.15493523e+00,
-1.40904987e+00, -1.54769256e+00, -1.51304634e+00, -1.45778996e+00])
)
12345678_0001
慕的地8271018
相关分类