When only one value in file, numpy.loadtxt() just returns the value instead of array, how to avoid?
Thank you in advance!
e.g. there's only 12345 in a file
12345.6
numpy.loadtxt() returns
12345.6
instead of
array([12345.6])
Use the ndmin parameter of numpy.loadtxt. Set it to 1, and you will always have an array with at least one dimension.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With