THE FILE FIELD GUIDE
.npy

NumPy Array

AI & Machine Learning

NPY stores a NumPy array with shape/type information. Meaning, units and preprocessing still need documentation. Arrays may represent images or numeric tables; do not assume an image from the suffix.

What it is used for
Storage of one array with type/shape information
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. Load with numpy.load while retaining allow_pickle=False.
  3. Inspect shape, dtype and array size against expected dimensions.
Large arrays: inspect a subset

Inspect a small sample before displaying all data.

  1. For supported numeric arrays, consider memory-mapped loading with mmap_mode.
  2. Read only a relevant slice and inspect missing or unexpected values.
  3. Preserve dtype while processing and save changes to a separate file.
Sharing as CSV or another format

Distinguish tabular arrays from higher-dimensional data.

  1. Inspect dimensions and column meanings and choose a tabular subset.
  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

  • Object array rejected: it may require pickle; do not enable it for unknown files.
  • Not a viewable image: inspect dimensions, channels, range and intended meaning.
  • Out of memory: review shape/type requirements and supported memory-mapping options.
  • Unreadable as text: NPY is binary; inspect it with NumPy shape/dtype.
  • Object-array loading rejected: investigate the required objects; do not enable pickle for unknown files.
  • Unexpected meaning: shape does not establish axis order or units; consult the producer.

Numeric NPY → CSV / visualization image

  1. Inspect numeric types/shape and document how dimensions map to table columns.
  2. For visualization, use documented ranges/channel interpretation and retain the original array.
  3. Compare element count, order, dtype, missing values and samples; record original shape and axis semantics.

CSV/images may lose type, precision or multidimensional structure; a colored visualization may not recover the original values.

Preserve array type and axes

NPY preserves dtype and dimensions, but arrays with identical shapes can have different axis meanings or units.

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

Pickled object arrays can execute code; retain allow_pickle=False for unknown data and review extreme sizes.

Questions and answers

Is NPY an image file?

It can store image arrays or many other kinds of data.

Should I enable allow_pickle?

Not for unknown data; establish trusted provenance.

Does it define units?

Type/shape alone do not establish units or meaning.

Does NPY contain all names and units?

It retains array shape/dtype, but application units and axis semantics may need separate documentation.

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 binary array format
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: