dpnp.ndarray.astype
- ndarray.astype(dtype, order='K', casting='unsafe', subok=True, copy=True, device=None)
- Copy the array with data type casting. - Refer to - dpnp.astypefor full documentation.- Parameters:
- x1 ({dpnp.ndarray, usm_ndarray}) -- Array data type casting. 
- dtype (dtype) -- Target data type. 
- order ({"C", "F", "A", "K"}, optional) -- Row-major (C-style) or column-major (Fortran-style) order. When - orderis 'A', it uses 'F' if- ais column-major and uses 'C' otherwise. And when- orderis 'K', it keeps strides as closely as possible.
- copy ({bool}, optional) -- If it is False and no cast happens, then this method returns the array itself. Otherwise, a copy is returned. 
- casting ({'no', 'equiv', 'safe', 'same_kind', 'unsafe'}, optional) -- - Controls what kind of data casting may occur. Defaults to - 'unsafe'for backwards compatibility.- 'no' means the data types should not be cast at all. 
- 'equiv' means only byte-order changes are allowed. 
- 'safe' means only casts which can preserve values are allowed. 
- 'same_kind' means only safe casts or casts within a kind, like float64 to float32, are allowed. 
- 'unsafe' means any data conversions may be done. 
 
- copy -- By default, - astypealways returns a newly allocated array. If this is set to- False, and the dtype, order, and subok requirements are satisfied, the input array is returned instead of a copy.
- device ({None, string, SyclDevice, SyclQueue}, optional) -- An array API concept of device where the output array is created. The device can be - None(the default), an OneAPI filter selector string, an instance of- dpctl.SyclDevicecorresponding to a non-partitioned SYCL device, an instance of- dpctl.SyclQueue, or a Device object returned by- dpnp.dpnp_array.dpnp_array.deviceproperty. Default:- None.
 
- Returns:
- arr_t -- Unless copy is - Falseand the other conditions for returning the input array are satisfied, arr_t is a new array of the same shape as the input array, with dtype, order given by dtype, order.
- Return type:
- dpnp.ndarray 
 - Limitations - Parameter subok is supported with default value. Otherwise - NotImplementedErrorexception will be raised.- Examples - >>> import dpnp as np >>> x = np.array([1, 2, 2.5]) >>> x array([1. , 2. , 2.5]) >>> x.astype(int) array([1, 2, 2])