• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 25, 2022 |260 Views
How to Change the Data Type of NumPy Array
  Share   Like
Description
Discussion

In this Video, we are going to see the ways in which we can change the dtype of the given numpy array. In order to change the dtype of the given array object, we will use numpy.astype() function. The function takes an argument which is the target data type. The function supports all the generic types and built-in types of data.

Problem #1 : Given a numpy array whose underlying data is of 'int32' type. Change the dtype of the given object to 'float64'.

Solution : We will use numpy.astype() function to change the data type of the underlying data of the given numpy array.

 

Related Article :  https://www.geeksforgeeks.org/change-data-type-of-given-numpy-array/