计算得出了一组2D的array命名为A,想将其转为pd.DataFrame后,再合并到一个DataFrame命名为B中,
同样的代码在while循环之前执行就没错,放到while里面就报下面的错。
AttributeError: ‘numpy.bool_’ object has no attribute ‘DataFrame’
只能通过下面这种一列一列的赋值,服了
B[‘new_col’] = A[:,0]
B[‘new_col_2’] = A[:,1]
在while外面,我可以通过下面方法合并
B = B.join(pd.DataFrame(A), rsuffix='_a')
sungod 未选择答案 2022年4月21日
同样的代码
#这里执行不报错
df = pd.DataFrame(A)
while 1:
api.wait_update()
if api.is_changing(klines):
#放到这里执行就报错了
df = pd.DataFrame(A)
报错并没有显示源代码文件具体报错,就显示当前文件报错的行,这就离谱
Traceback (most recent call last):
File “C:/Users/test.py”, line 176, in
a = pd.DataFrame()
AttributeError: ‘numpy.bool_’ object has no attribute ‘DataFrame’