I have a dataframe (size: 71363 x 7) of float values I want to extract to csv:
df.to_csv('title', sep ='\t', header=None, index=False)
However, as some cells have more or less decimals than others, the .csv file looks something like:
GRID 111163.0 100000.0 7.931 -0.061 1.798 100010.0
GRID 111164.0 100000.0 7.936 -0.057 1.8 100010.0
GRID 111165.0 100000.0 7.893 -0.025 1.781 100010.0
GRID 119347.0 100000.0 7.692 0.631 1.703 100010.0
GRID 119348.0 100000.0 7.686 0.635 1.7 100010.0
GRID 119385.0 100000.0 7.68 0.651 1.698 100010.0
Instead of something clean like :
GRID 111163.0 100000.0 7.931 -0.061 1.798 100010.0
GRID 111164.0 100000.0 7.936 -0.057 1.8 100010.0
GRID 111165.0 100000.0 7.893 -0.025 1.781 100010.0
GRID 119347.0 100000.0 7.692 0.631 1.703 100010.0
GRID 119348.0 100000.0 7.686 0.635 1.7 100010.0
GRID 119385.0 100000.0 7.68 0.651 1.698 100010.0
I tried to force a "round" to my columns :
grid_rep_coq[[1,2,3,4,5,6]] = round(grid_rep_coq[[1,2,3,4,5,6]], 3)
But any value of less than 3 decimals doesn't change and I therefore have the same issue.
I couldn't find any documentation on forcing a tab separator.
Would anyone know how to do this?
Thank you in advance!