Either you find a way to get the output with the correct type or you use astype, see the docs, in order to change the type of an array

In your case the following example gives you an array of type np.int

c=random.randn(5,5).astype(np.int)
Answer from plonser on Stack Overflow
🌐
w3resource
w3resource.com › python-exercises › numpy › python-numpy-exercise-39.php
NumPy: Change the data type of an array - w3resource
y = x.astype(float): The current line creates a new array ‘y’ by changing the data type of ‘x’ to float.
🌐
W3Schools
w3schools.com › python › numpy › numpy_data_types.asp
NumPy Data Types
The astype() function creates a copy of the array, and allows you to specify the data type as a parameter. The data type can be specified using a string, like 'f' for float, 'i' for integer etc. or you can use the data type directly like float ...
🌐
Tutorialsandyou
tutorialsandyou.com › python › how-to-change-data-type-of-a-given-numpy-array-79.html
How to change data type of a given Numpy array | ndarray.astype()
Array a: [12 24 36 48] Data type of array a: int64 Data type of array a after calling astype(): float64 Array a: [12. 24. 36. 48.] Example 2: In this example, we will change the data type of array from float64 to complex128
🌐
CodeSpeedy
codespeedy.com › home › change datatype of a numpy array in python
Change Datatype of a NumPy array in Python - CodeSpeedy
February 16, 2022 - Now let’s change the data type of the array we have just made using astype() function. First, let’s convert it into data type float and then print the array and its datatype as:
🌐
Educative
educative.io › answers › how-to-convert-data-types-of-arrays-using-numpy-in-python
How to convert data types of arrays using NumPy in Python
We use the dtype property to check for the data type. We make a copy of the array and use the array.astype() method to change its data type.
🌐
YouTube
youtube.com › watch
How to Change the Data Type of NumPy Array? | GeeksforGeeks - YouTube
In this video, we're going to discuss how to change the datatype of the Numpy Array. Here, we'll be using the .astype() function in order to change the datat...
Published   June 23, 2021
🌐
TutorialsPoint
tutorialspoint.com › change-data-type-of-given-numpy-array-in-python
Change data type of given numpy array in Python
January 2, 2020 - We have a method called astype(data_type) to change the data type of a numpy array. If we have a numpy array of type float64, then we can change it to int32 by giving the data type to the astype() method of numpy array.
Find elsewhere
🌐
woteq
woteq.com › home › how to change the data type of a numpy array in python
How to Change the Data Type of a NumPy Array in Python - Woteq Zone
February 10, 2026 - Learn how to change NumPy array data types in Python using astype() and view() methods. Understand int, float, bool conversions for data analysis with practical examples.
🌐
GeeksforGeeks
geeksforgeeks.org › numpy › change-numpy-array-data-type
Change the Data Type of the Given NumPy Array - GeeksforGeeks
In this tutorial, we have covered the best way to change the data type of the given NumPy array with astype() method. We have provided an easy explanation for the method and also covered sample problems/examples to provide a better understanding ...
Published   July 11, 2025
🌐
GeeksforGeeks
geeksforgeeks.org › videos › how-to-change-the-data-type-of-numpy-array
How to Change the Data Type of NumPy Array - GeeksforGeeks | Videos
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/ ... Command Line Arguments in Python.
Published   October 25, 2022
Views   500
🌐
Scaler
scaler.com › home › topics › numpy › manipulating data types in numpy
Manipulating Data Types in NumPy - Scaler Topics
November 9, 2022 - A NumPy array in Python has a data type called dtype, which can be specified when creating an array using the np.array() function. To change the data type of an array, we use the astype() function that is provided by NumPy in Python.
🌐
GeeksforGeeks
geeksforgeeks.org › change-data-type-of-given-numpy-array
Change data type of given numpy array - GeeksforGeeks
August 9, 2021 - In this post, 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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › videos › how-to-change-the-data-type-of-numpy-array-python
How to Change the Data Type of NumPy Array? | Python - GeeksforGeeks | Videos
This function supports all the generic & built-in types of data and just takes an argument which is the target data type. So, let's get started now. Check Out the Related Article: https://www.geeksforgeeks.org/change-numpy-array-data-type/ ... Iterate over a list in Python.
Published   April 8, 2024
Views   2K
🌐
Stack Overflow
stackoverflow.com › questions › 62658068 › change-datatype-of-array-in-python
pandas - Change datatype of array in python - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... With this code after the numpy import, it works. :-) import numpy as np _oldarray = np.array def array32(*args, **kwargs): if 'dtype' not in kwargs: kwargs.update(dtype=float32) _oldarray(*args, **kwargs) np.array = _oldarray
🌐
Tutorial Reference
tutorialreference.com › python › examples › faq › python-numpy-how-to-change-array-data-type
Python NumPy: How to Change NumPy Array Data Type in Python | Tutorial Reference
NumPy's astype() method provides flexible type conversion while preserving array structure. The astype() method creates a new array with the specified data type: ... Converting float to integer truncates the decimal portion rather than rounding. Use np.round(), np.floor(), or np.ceil() first ...
🌐
Note.nkmk.me
note.nkmk.me › home › python › numpy
NumPy: astype() to change dtype of an array | note.nkmk.me
February 4, 2024 - For processes where bit size is crucial, it is safer to explicitly convert to the desired type with astype() beforehand. print((a_int16 + a_float16).dtype) # float32 print((a_int32 + a_float32).dtype) # float64 ... Note that when assigning values to elements, the dtype does not change. For example, if a floating-point number is assigned to an array of int, the ndarray data type remains int.