I have a following numpy array:
geom= [[ 6. 0.2 -1.6 -1.3915 ]
[ 6. 1.40507435 -1.6 -0.69575 ]
[ 6. 1.40507435 -1.6 0.69575 ]
[ 6. 0.2 -1.6 1.3915 ]
[ 6. -1.00507435 -1.6 0.69575 ]
[ 6. -1.00507435 -1.6 -0.69575 ]]
When I save it to the file :
np.savetxt(g, geom, fmt ='%f6', delimiter=' ', newline='\n', header='', footer='', comments='# ')
My first column gets a format '6.0000008'. Subsequently I want to modify that file to obtain 6.0 or 6. Is there any easy solution to do it? I have tried to convert string to int, but I am getting the error message in return:
ValueError: invalid literal for int() with base 10: '6.0000008'
pandasinstead of numpy. It lets you easily combine data of different types into a single dataframe, which can then be exported to file in a much cleaner way.