I am running some numerical simulations with python, pandas and scipy. I run a set of scenarios, and for each scenario I create a detailed dataframe with lots of outputs, which I save to separate CSV files. Each CSV file is about 900 KB.
The line I use is, banally:
mydataframe.to_csv('myoutput.csv')
My question is: is there a way to speed the exporting process? Some specific parameters, a different library, etc. I ask because writing to CSV takes almost half the time of the total simulation: running 18 scenarios takes 17 seconds, 7.2 of which spent in the to_csv method.
PS I had initially wanted to write to Excel, but that's too slow, as per my other question: Python: fastest way to write pandas DataFrame to Excel on multiple sheets