tushare获取数据,写入excel,

#注册tushare https://tushare.pro/register?reg=301280
#安装pandas库
#安装tushare库
import tushare as ts
import pandas as pd
df=ts.get_all_day
df.to_excel(‘c:/888/文件名.xlsx’)

#多个df写入excel
writer=pd.ExcelWriter(‘test1.xlsx’)
df1=ts.get_area_classified()
df2=ts.get_day_all()
df1.to_excel(writer)
df2.to_excel(writer,startrow=0,startcol=100)
#row是行,col是列
writer.save()

#追加模式写入csv,不覆盖原有数据
df.to_csv(write,mode=‘a’,encoding=‘utf-8’)
#获取dataframe的标量值
nf = df.iat[0,0]

你可能感兴趣的:(tushare获取数据,写入excel,)