Say I have a function pivots() which aggregates pivot tables
def pivots():
d = data() #another function which cleans up my raw data
price_floor = PF(d)
no_floor = NF(d)
return price_floor,no_floor
I know how to export a single pivot table
q,r = pivots()
q.to_csv('C:\\export.csv')
But it would be so much more convenient if I could export both price_floor and no_floor to the same document 'export.csv'
You can use to_csv(path, mode='a')
to append files.
# default 'w' write mode
q.to_csv('C:\\export.csv')
# explicitly specify 'a' append mode
r.to_csv('C:\\export.csv', mode='a')
# Use header=False
# if you don't want to write headers while appending
r.to_csv('C:\\export.csv', mode='a', header=False)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.