NumPy Array
AI & Machine LearningNPY 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.
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
- Inspect numeric types/shape and document how dimensions map to table columns.
- For visualization, use documented ranges/channel interpretation and retain the original array.
- 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
| Format | Main role | What to check |
|---|---|---|
| NPY | Single array | Shape/dtype and axis semantics |
| NPZ | Multiple-array archive | Keys and array relationships |
| CSV | Table exchange | Manage 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: