numpy.savetxt- Save one column as int and the rest as floats?
As @wflynny, but with out join
:
np.savetxt('array.txt', data, fmt='%i'+' %1.4f'*N)
data
has 3 columns, so you need supply 3 '%format'
s. For example:
np.savetxt('array.txt', data, fmt='%i %1.4f %1.4f')
should work. If you have a lot more than 3 columns, you can try something like:
np.savetxt('array.txt', data, fmt=' '.join(['%i'] + ['%1.4f']*N))
where N
is the number of columns needing float formatting.