Python pandas csv exporting

I have a problem exporting a data file to a CSV file.

Data types are String and Float64 values, such as:

In [19]: segmenti_t0 Out[19]: SEGM1 SEGM2 AD PS 8.3 SCREMATO 0.6 CRE STD 1.2 FUN INTERO 0.0 PS 2.0 SCREMATO 0.0 NORM INTERO 13.1 PS 69.5 SCREMATO 5.2 Name: Quota volume_t0 

I am trying to export this dataframe with this command:

 IN [20]: segmenti_t0.to_csv('C:Users\MarioRossi\prova.csv', sep=";") 

When I try to open it using Excel or try to import it into excel from a csv file with formatting options, I get really strange formatting for float values, for example, 69.5000 or 5.2.0000000 or date formatting the same way:

 NORM INTERO 13.01 NORM PS 69.05.00 NORM SCREMATO 5.02 

We believe that I use the European format ("," as decimal, as I use to import the original raw data from csv files).

Please help me: I have developed software (with a graphical interface, etc.) and I cannot deliver it for this reason!

thanks

+7
source share
1 answer

You should use the to_excel DataFrame method:

 # first convert Series to DataFrame df_segmenti_t0 = DataFrame(segmenti_t0) # save as excel spreadsheet df_segmenti_t0.to_excel('prova.xls') 
+6
source

All Articles