Use numpy.full():

import numpy as np

np.full(
  shape=10,
  fill_value=3,
  dtype=np.int
)
    
> array([3, 3, 3, 3, 3, 3, 3, 3, 3, 3])
Answer from Daniel Lenz on Stack Overflow
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ basics.creation.html
Array creation โ€” NumPy v2.5.dev0 Manual
When you perform operations with different dtype, NumPy will assign a new type that satisfies all of the array elements involved in the computation, here uint32 and int32 can both be represented in as int64. The default NumPy behavior is to create arrays in either 32 or 64-bit signed integers ...
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ basic โ€บ numpy-basic-exercise-14.php
NumPy: Create an array of the integers from 30 to 70 - w3resource
August 28, 2025 - This NumPy program generates an array of integers ranging from 30 to 70. By using NumPy's array creation functions, it efficiently constructs the array with the specified sequence of integers.
Discussions

python: converting an numpy array data type from int64 to int - Stack Overflow
I am somewhat new to python and I am using python modules in another program (ABAQUS). The question, however, is completely python related. In the program, I need to create an array of integers. T... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Python numpy arrays staying integers - Stack Overflow
I'm currently taking a numerical methods class and wrote a function to carry out Gauss Elimination. I noticed that for some reason when carrying out operations on a numpy array, python fails to convert integers into floats. so I'm getting zeros instead of a float. More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - Convert 2D float array to 2D int array in NumPy - Stack Overflow
How do I convert a float NumPy array into an int NumPy array? More on stackoverflow.com
๐ŸŒ stackoverflow.com
June 28, 2020
python - Convert ndarray from float64 to integer - Stack Overflow
I'd like to convert the array to be an array of integers. How should I do this? int() won't work, as it says it can't convert it to a scalar. Changing the dtype field itself obviously doesn't work, as the actual bytes haven't changed. I can't seem to find anything on Google or in the documentation - what's the best way to do this? ... Use .astype. >>> a = numpy... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ converting-numpy-array-values-into-integers-a-comprehensive-guide
Converting Numpy Array Values into Integers: A Guide | Saturn Cloud Blog
December 2, 2023 - The astype(int) function converts the floating-point numbers in the array to integers. Note that this function truncates the decimal part of the number, rather than rounding to the nearest integer.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ basics.types.html
Data types โ€” NumPy v2.5.dev0 Manual
NumPy generally returns elements of arrays as array scalars (a scalar with an associated dtype). Array scalars differ from Python scalars, but for the most part they can be used interchangeably (the primary exception is for versions of Python older than v2.x, where integer array scalars cannot act as indices for lists and tuples).
๐ŸŒ
SciPy Lecture Notes
scipy-lectures.org โ€บ intro โ€บ numpy โ€บ array_object.html
1.4.1. The NumPy array object โ€” Scipy lecture notes
NumPy arrays can be indexed with slices, but also with boolean or integer arrays (masks). This method is called fancy indexing. It creates copies not views. ... When a new array is created by indexing with an array of integers, the new array has the same shape as the array of integers:
Find elsewhere
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ basics.creation.html
Array creation โ€” NumPy v2.4 Manual
When you perform operations with different dtype, NumPy will assign a new type that satisfies all of the array elements involved in the computation, here uint32 and int32 can both be represented in as int64. The default NumPy behavior is to create arrays in either 32 or 64-bit signed integers ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_data_types.asp
NumPy Data Types
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 for float and int for integer. Change data type from float to integer by using 'i' as parameter value: import ...
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ numpy โ€บ python-numpy-exercise-82.php
NumPy: Convert a NumPy array of float values to a NumPy array of integer values - w3resource
August 29, 2025 - 12.51] [ 2.34 7.98] [ 25.23 36.5 ]] Convert float values to integer values: [[12 12] [ 2 7] [25 36]] ... x = np.array([[12.0, 12.51], [2.34, 7.98], [25.23, 36.50]]): This line creates a NumPy array x with the given float values.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_creating_arrays.asp
NumPy Creating Arrays
Create a 3-D array with two 2-D ... Try it Yourself ยป ยท NumPy Arrays provides the ndim attribute that returns an integer that tells us how many dimensions the array have....
๐ŸŒ
FutureLearn
futurelearn.com โ€บ home โ€บ blog
Creating and accessing NumPy arrays
October 25, 2022 - This will generate a NumPy array containing four elements of integer type.
๐ŸŒ
Python Like You Mean It
pythonlikeyoumeanit.com โ€บ Module3_IntroducingNumpy โ€บ FunctionsForCreatingNumpyArrays.html
Functions for Creating NumPy Arrays โ€” Python Like You Mean It
NumPy provides additional functions for creating constant-valued arrays. Please refer to the official documentation for a complete listing. The arange function allows you to initialize a sequence of integers based on a starting point (inclusive), stopping point (exclusive), and step size.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ reference โ€บ generated โ€บ numpy.ndarray.astype.html
numpy.ndarray.astype โ€” NumPy v2.4 Manual
June 22, 2021 - By default, astype always 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.
๐ŸŒ
Pp4rs
pp4rs.github.io โ€บ pp4rs-python โ€บ notebooks โ€บ numpy โ€บ 01-create_array.html
Numpy Basics - Creating Arrays โ€” Python for Economics and Business Research
We often will not want to manually enter the contents of an array ourselves. It is more efficient to create arrays from scratch using routines built into NumPy. Here are several examples, including extensions to creating 2-D arrays: # Create a length-10 integer array filled with integer zeros np.zeros(10, dtype=int)
๐ŸŒ
O'Reilly
oreilly.com โ€บ library โ€บ view โ€บ scikit-learn-cookbook โ€บ 9781787286382 โ€บ 234bd529-7a58-4ec4-8782-88e53c07f87d.xhtml
Initializing NumPy arrays and dtypes - scikit-learn Cookbook , Second Edition - Second Edition [Book]
November 16, 2017 - It remains the same throughout the array. Every single element of the array below has a np.int integer type. np.ones((5,2), dtype = np.int)array([[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]])
Authors ย  Julian AvilaTrent Hauck
Published ย  2017
Pages ย  374