遇到的问题---python---pandas新建空的dataframe报错dataframe type object ‘object‘ has no attribute ‘dtype‘
情况
处理一些数据,需要新建一个dataframe,后续再新增数据进去,使用代码如下:
df=pd.DataFrame(columns=['code', 'name'])
for row in results:
i= i+1
print(i)
print("总数%s, 当前%s 编码%s" % (str(cursor.rowcount), str(i), row[0]))
codeValue = row[0]
nameValue = row[1]
temp=[{'code':codeValue,'name':nameValue}]
df=df.append(temp)
报错AttributeError: type object ‘object’ has no attribute ‘dtype’如下:
Traceback (most recent call last):
File "/Users/joe/workspace/stock/tianyan_py/tianyan_py/__init__.py", line 72, in <module>
init()
File "/Users/joe/workspace/stock/tianyan_py/tianyan_py/__init__.py", line 32, in init
get_today_by_xueqiu()
File "/Users/joe/workspace/stock/tianyan_py/tianyan_py/main.py", line 754, in get_today_by_xueqiu
df=pd.DataFrame(colu
还没有评论,来说两句吧...