Python导出csv数据
to_csv(filePath,sep=",",index=TRUE,header=TRUE)
sep分隔符,默认为逗号(“,”)
index是否导出行序号,默认为TRUE
header是否导出列名,默认为TRUE
从Tushare库获取股票数据,并导出
import tushare as ts
df=ts.sh_margins(start='2015-01-01', end='2015-04-19')
df.to_csv("d://df.csv")
df文件打开为:
import tushare as ts
ab=ts.sh_margins(start='2015-01-01', end='2015-04-19')
ab.to_csv("d://ab.csv", index=False)
若index改为false,则: