statsmodels.iolib.foreign.savetxt(fname, X, names=None, fmt='%.18e', delimiter=' ')
[source]
Save an array to a text file.
This is just a copy of numpy.savetxt patched to support structured arrays or a header of names. Does not include py3 support now in savetxt.
Parameters: |
|
---|
See also
save
.npy
formatsavez
.npz
compressed archiveFurther explanation of the fmt
parameter (%[flag]width[.precision]specifier
):
-
: left justify
+
: Forces to preceed result with + or -.
0
: Left pad the number with zeros instead of space (see width).
d,i,o,x
), the minimum number of digits.e, E
and f
specifiers, the number of digits to print after the decimal point.g
and G
, the maximum number of significant digits.s
, the maximum number of characters.c
: character
d
or i
: signed decimal integer
e
or E
: scientific notation with e
or E
.
f
: decimal floating point
g,G
: use the shorter of e,E
or f
o
: signed octal
s
: string of characters
u
: unsigned decimal integer
x,X
: unsigned hexadecimal integer
This explanation of fmt
is not complete, for an exhaustive specification see [1].
[1] | Format Specification Mini-Language, Python Documentation. |
>>> savetxt('test.out', x, delimiter=',') # x is an array >>> savetxt('test.out', (x,y,z)) # x,y,z equal sized 1D arrays >>> savetxt('test.out', x, fmt='%1.4e') # use exponential notation
© 2009–2012 Statsmodels Developers
© 2006–2008 Scipy Developers
© 2006 Jonathan E. Taylor
Licensed under the 3-clause BSD License.
http://www.statsmodels.org/stable/generated/statsmodels.iolib.foreign.savetxt.html