Pandas writes field names when exporting CSV Python

1

I am programming a small development, but I have problems writing to a CSV I do not want panda to write the name of the fields, but I could not delete this option, I read the documentation and added the argument "index_label = False" e " index = False "when exporting the file as follows:

   import pandas as pd

    a=[1,2,3,4,5]
    b=[6,7,8,9,10]
    expHISTORIA=pd.DataFrame([a,b]).transpose() #crear DataFrame
    expHISTORIA.to_csv('Historias.csv',index=False,index_label=False, mode='a',sep=';') #crear el CSV

The problem is that the generated file contains fields, I want you not to print them that only generates the file with the data.

What you print is the following:

   0    1
   1    6
   2    7
   3    8
   4    9
   5    10

But the first two numbers are (0, 1) are fields that are created automatically and I do not want them to be. Ideally, print this:

   1    6
   2    7
   3    8
   4    9
   5    10
    
asked by Jorge Ponti 10.08.2017 в 18:38
source

1 answer

1

Try this:

df.to_csv('your_array.csv', header=False, index=False)

header is a Boolean parameter in which you define whether or not you want to write the dataframe headers.

    
answered by 10.08.2017 / 18:57
source