May-18-2018, 03:00 AM
Default format string (
fmt
parameter) for the np.savetxt
method coincide to floating point numbers, so, you need to change fmt
to '%s' (strings):import numpy as np x = [['ABC', 123.45], ['DEF', 678.90]] np.savetxt('text.txt', x, fmt='%s') # default dtype for np.loadtxt is also floating point, change it, to be able to load mixed data. y = np.loadtxt('text.txt', dtype=np.object)