大家好!
我将上图中的excel表格导入python生成一个Dataframe
现在我要使用Tushare的行情查询A列中每个股票在日期start_date的收盘价,并填入start_date_price列的相应行中;
我的代码如下:
df = pd.read_csv('D:/private/stock investment/st_research.csv')
code=list(df['ts_code'])
start_date=list(str(df['start_date']))
for x,y in zip(code,start_date):
result=ts.pro_bar(ts_code=x, adj='qfq',start_date=y)
#将查询到的收盘价close填入start_date_price列的相应行中
df.loc[df[df.ts_code == x].index.tolist(),'start_date_price'] = result.loc[0,'close']
print(df.head())
结果报错如下图:
请问是什么问题,如何解决?谢谢!
result=ts.pro_bar(ts_code=x, adj='qfq',start_date=y)
查一下这一句,是不是pro_bar返回的是None
你这个result=ts.pro_bar(ts_code=x, adj='qfq',start_date=y)
ts.pro_bar(ts_code=x, adj='qfq',start_date=y)返回的是个None值