THE FILE FIELD GUIDE
.npz

NumPy Array Archive

AI & Machine Learning

NPZ collects NPY arrays. Named arrays may have different shapes/types and need not form one table. Inspect names and per-array specifications, then compare their meaning with producer documentation.

What it is used for
Storage of a named collection of arrays
What the file contains
Binary data
All sections, questions and sources

Content reviewed: · Editor:Kai

Opening steps

Choose your environment or purpose to see its steps.

Python: inspect array information

Inspect dtype and shape before computing.

  1. Copy the original and check axis meanings, units and the producer’s NumPy environment.
  2. Keep allow_pickle=False with numpy.load and inspect array names through files first.
  3. Inspect shape/dtype for the needed keys and close the archive after use.
Multiple arrays: inspect relationships

Inspect a small sample before displaying all data.

  1. List keys and identify image, label and ID arrays.
  2. Compare sample counts and axes and verify row alignment across arrays.
  3. Process only the required arrays; reload if needed after closing.
Sharing as CSV or another format

Distinguish tabular arrays from higher-dimensional data.

  1. Select the array key and check whether its shape suits a table.
  2. Export with explicit axes/types when needed and preserve units/column names separately.
  3. Reload and compare shape, ordering, integer precision and missing values.

Menu labels and support vary by app, OS and version. Preserve the original before making changes.

Troubleshooting by symptom

  • Missing key: inspect member names and compare producer naming.
  • Different shapes: identify each array’s role/dimensional relationships.
  • Object-array failure: do not enable pickle to load unknown members.
  • Unclear arr_0-style keys: inspect the save code to identify unnamed arrays.
  • Object-array loading rejected: investigate the required objects; do not enable pickle for unknown files.
  • Memory mapping does not help: NPZ archives NPY arrays; consider storing needed numeric arrays separately.

NPZ → individual NPY / CSV

  1. Record member names/types/shapes and select required arrays.
  2. Save individual arrays as NPY; for CSV document dimension/column mapping and compare values.
  3. Compare element count, order, dtype, missing values and samples; record original shape and axis semantics.

One CSV cannot retain equivalent member names/different shapes; renaming ZIP does not explain the arrays’ meaning.

Manage related arrays together

Related data and labels need matching order as well as counts; document keys, shapes and alignment.

Inspect samples rather than displaying everything; choose processing suitable for dtype and value range.

Source for these steps:NumPy Project · numpy.lib.format / NumPy Project · numpy.load / NumPy Project · Reading and writing files

Information that CSV may lose

CSV may not preserve NumPy types or multidimensional structure; document flattened axes and original shape and include the source when needed.

Object arrays can require pickle loading; retain protections and ask the producer for an appropriate non-object export.

Source for these steps:NumPy Project · numpy.lib.format / NumPy Project · numpy.load / NumPy Project · Reading and writing files

Related-format differences

Related-format differences
FormatMain roleWhat to check
NPYSingle arrayShape/dtype and axis semantics
NPZMultiple-array archiveKeys and array relationships
CSVTable exchangeManage type/structure separately

Handling and security

Do not infer memory needs from compressed size; keep pickle disabled for unknown object arrays and inspect only needed data.

Questions and answers

Is it always compressed?

Compression depends on the saving method.

Are member names standardized?

Names depend on the producer; inspect the list first.

Can I directly make one CSV?

First define the table structure from the arrays’ shapes/meaning.

Is NPZ one compressed NPY?

It can contain multiple named arrays; compression depends on the save API.

What should I check when sharing with Excel?

Check multidimensional layout, large integers, missing values and dates and compare values after reloading.

Format facts: name, steward and MIME type
Formal name
NumPy array archive
Steward / specification
NumPy Project
MIME type
Depends on the producer or server; an extension alone does not establish a MIME type.

Primary and official sources

  • Project documentationnumpy.lib.format

    Specification of NPY and NPZ array storage.

    NumPy Project · Link checked:
  • Project documentationnumpy.load

    Documents object arrays and allow_pickle.

    NumPy Project · Link checked:
  • Project documentationReading and writing files

    Reference for array and text-file I/O.

    NumPy Project · Link checked: