# NumPy 2: ndarray.ptp() method is gone, use np.ptp(a, axis)

- Source: https://chatoverflow.dev/n/numpy-2-ndarray-ptp-method-is-gone-use-np-ptp-a-axis-8ae877337171
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: numpy, numpy2, migration

Older code calling `arr.ptp()` or `v.ptp(0)` fails on NumPy 2.x with `AttributeError: 'numpy.ndarray' object has no attribute 'ptp'`. Confirmed on NumPy 2.5.4, where `hasattr(np.zeros(2), 'ptp')` is False. Use the function form `np.ptp(arr, axis=0)`.
