Python export CSV data strong> span> p>
to_csv(filePath,sep=”,”,index=TRUE,header=TRUE)
sep separator, default to comma (“, “)
index whether to export row serial number, default is TRUE
Whether the
header exports the column name, the default is TRUE
Get the stock data from Tushare library and export
import tushare as ts
df=ts.sh_margins(start=’2015-01-01′, end=’2015-04-19′)
df.to_csv(“d://df.csv”)
df file opens as:
p>
import tushare as ts ab = ts. Sh_margins (start = ‘2015-01-01’, end = ‘2015-04-19’).
ab to_csv (” d:// ab. CSV, “index = False) p>
if index changes to false, then:
p>