Input and output

NumPy binary files (NPY, NPZ)

methoddescription
loadopen in new window(file[, mmap_mode, allow_pickle, …])Load arrays or pickled objects from .npy, .npz or pickled files.
saveopen in new window(file, arr[, allow_pickle, fix_imports])Save an array to a binary file in NumPy .npy format.
savezopen in new window(file, *args, **kwds)Save several arrays into a single file in uncompressed .npz format.
savez_compressedopen in new window(file, *args, **kwds)Save several arrays into a single file in compressed .npz format.

The format of these binary file types is documented in numpy.lib.formatopen in new window

Text files

methoddescription
loadtxtopen in new window(fname[, dtype, comments, delimiter, …])Load data from a text file.
savetxtopen in new window(fname, X[, fmt, delimiter, newline, …])Save an array to a text file.
genfromtxtopen in new window(fname[, dtype, comments, …])Load data from a text file, with missing values handled as specified.
fromregexopen in new window(file, regexp, dtype[, encoding])Construct an array from a text file, using regular expression parsing.
fromstringopen in new window(string[, dtype, count, sep])A new 1-D array initialized from text data in a string.
ndarray.tofileopen in new window(fid[, sep, format])Write array to a file as text or binary (default).
ndarray.tolistopen in new window()Return the array as an a.ndim-levels deep nested list of Python scalars.

Raw binary files

methoddescription
fromfileopen in new window(file[, dtype, count, sep, offset])Construct an array from data in a text or binary file.
ndarray.tofileopen in new window(fid[, sep, format])Write array to a file as text or binary (default).

String formatting

methoddescription
array2stringopen in new window(a[, max_line_width, precision, …])Return a string representation of an array.
array_repropen in new window(arr[, max_line_width, precision, …])Return the string representation of an array.
array_stropen in new window(a[, max_line_width, precision, …])Return a string representation of the data in an array.
format_float_positionalopen in new window(x[, precision, …])Format a floating-point scalar as a decimal string in positional notation.
format_float_scientificopen in new window(x[, precision, …])Format a floating-point scalar as a decimal string in scientific notation.

Memory mapping files

methoddescription
memmapopen in new windowCreate a memory-map to an array stored in a binary file on disk.

Text formatting options

methoddescription
set_printoptionsopen in new window([precision, threshold, …])Set printing options.
get_printoptionsopen in new window()Return the current print options.
set_string_functionopen in new window(f[, repr])Set a Python function to be used when pretty printing arrays.
printoptionsopen in new window(\*args, \*\*kwargs)Context manager for setting print options.

Base-n representations

methoddescription
binary_repropen in new window(num[, width])Return the binary representation of the input number as a string.
base_repropen in new window(number[, base, padding])Return a string representation of a number in the given base system.

Data sources

methoddescription
DataSourceopen in new window([destpath])A generic data source file (file, http, ftp, …).

Binary Format Description

methoddescription
lib.formatopen in new windowBinary serialization