I have a problem when I export to csv a dataframe. I have a column number for example 1520, but when I export to csv using to_csv , in te file I find the number 1520.0 with decimal, is possible eliminate the ".0" and only preserve the number "1520" ?
todo.to_csv('D:\prueba.csv', sep=',',header=False,index=False)
I had resolved with this code, but is complicate when I have a lot of columns
for i in range(81,698):
print("Creacion de archivo LOTE_AMD_M{0}.csv".format(i))
data = pandas.read_sql(sql2.format(i),cnxn)
todo=pandas.concat([dat,data])
ruta='D:\descarga\LOTE_AMD_M{0}.csv'.format(i)
r=todo
r=r.fillna('')
archivo= open(ruta,"a")
count=0
for index,row in r.iterrows():
d=''
for j in list(todo):
if j == 'C1':
t=str(row[j])
d+=",{0}".format(t[0:len(t)-2])
else:
d+=",{0}".format(row[j])
archivo.write(d[1:len(d)]+'\n')
count+=1
if count%1000==0:
print("se han insertado ",count," lineas")
archivo.close()
print("termino Carga SQL Query")