import numpy as np print (' Specify the data type when generating an array ') arr = np.array([1, 2, 3], dtype =
np.float64) print (arr.dtype) arr = np.array([1, 2, 3], dtype = np.int32) print
(arr.dtype) print ( ) print (' use astype Copy array and convert data type ') int_arr = np.array([1, 2,
3, 4, 5]) float_arr = int_arr.astype(np.float) print (int_arr.dtype) print
(float_arr.dtype) print( ) print (' use astype take float Convert to int The decimal part is discarded ') float_arr =
np.array([3.7, -1.2, -2.6, 0.5, 12.9, 10.1]) int_arr = float_arr.astype(dtype =
np.int) print (int_arr) print( ) print (' use astype Convert a string to an array , If it fails, an exception is thrown .') str_arr
= np.array(['1.25', '-9.6', '42'], dtype = np.string_) float_arr =
str_arr.astype(dtype = np.float) print (float_arr) print() print
('astype Use the data types of other arrays as parameters ') int_arr = np.arange(10) float_arr = np.array([.23,
0.270, .357, 0.44, 0.5], dtype = np.float64) print
(int_arr.astype(float_arr.dtype)) print (int_arr[0], int_arr[1]) #
astype Made a copy , The array itself does not change .

Technology
©2019-2020 Toolsou All rights reserved,
One is called “ Asking for the train ” A small village Finally got the train SparkSQL Achieve partition overlay write Character recognition technology of vehicle license plate based on Neural Network c++ Memory Pointer out of bounds detection mechanism _CrtMemBlockHeade Change one's mind ! Tesla starts to deliver made in China to European market Model 3Qt study 7—— Modal and modeless dialog boxes JavaScript Medium Call and ApplyJAVA Convert a string to a numeric type k8s Entry to give up --k8s Key concepts Count the number of letters (java Language implementation )