Skip to content
masterclass Buddy

NumPy · Method

ndarray.astype

ndarray.astype converts an array to a requested data type. It normally returns a new array, and its casting rules control which conversions are allowed.

Last updated

Since
2.4

Syntax

ndarray.astype(dtype, order='K', casting='unsafe', subok=True, copy=True)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • ndarray.copy
  • ndarray.view
  • numpy.astype

Source: numpy.ndarray.astype — NumPy v2.5 Manual. Checked 2026-11-03.