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
๐ŸŒ
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 - By using NumPy's array creation functions, it efficiently constructs the array with the specified sequence of integers. This program highlights how to create arrays with defined ranges in a straightforward manner.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ basics.creation.html
Array creation โ€” NumPy v2.6.dev0 Manual
NumPy arrays can be defined using Python sequences such as lists and tuples. Lists and tuples are defined using [...] and (...), respectively.
Discussions

python - How to create a numpy array of N numbers of the same value? - Stack Overflow
I realize it's not using numpy, but this is very easy with base python. 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 con... More on stackoverflow.com
๐ŸŒ stackoverflow.com
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
Numpy : why cant numpy cast uint in int

NumPy functions are designed to have consistent return dtypes, based only on the dtypes of their arguments. This is an essential feature for avoiding bugs based on strange input values, and lets you accelerate numpy functions with tools like Numba.

Not every signed int can be safely cast into a unsigned int of the same size (e.g., 2 ** 63 is a valid 64-bit unsigned int but not a valid signed int). Likewise, not every signed int can be cast into an unsigned int (consider negative numbers). Hence, NumPy uses the next largest size dtype that can hold both values. 64-bits are the largest size integers supported by numpy, so it uses float64 instead. In contrast, as shown in the other comment, uint16 + int16 can fit in int32.

In contrast, np.arraycoerces dtypes of input arrays. This means it always succeeds.... even if the values cannot be safely represented:

In [31]: np.array(np.arange(2 ** 40, 2 ** 40 + 3), dtype=np.int16)
Out[31]: array([0, 1, 2], dtype=int16)
More on reddit.com
๐ŸŒ r/Python
4
3
June 1, 2015
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_data_types.asp
NumPy Data Types
NumPy has some extra data types, and refer to data types with one character, like i for integers, u for unsigned integers etc. Below is a list of all data types in NumPy and the characters used to represent them. ... import numpy as np arr = np.array(['apple', 'banana', 'cherry']) print(arr.dtype) Try it Yourself ยป
๐ŸŒ
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
May 1, 2026 - Numpy provides several functions to convert the data types of numbers. The astype() function is one of the most commonly used functions for this purpose. Letโ€™s dive into how you can use this function to convert Numpy array values into integers.
๐ŸŒ
NumPy
numpy.org โ€บ devdocs โ€บ user โ€บ basics.types.html
Data types โ€” NumPy v2.6.dev0 Manual
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). There are some exceptions, such as when code requires very specific attributes of a scalar or when it checks specifically whether a value is a Python scalar.
๐ŸŒ
Pp4rs
pp4rs.github.io โ€บ pp4rs-python โ€บ notebooks โ€บ numpy โ€บ 01-create_array.html
Numpy Basics - Creating Arrays โ€” Python for Economics and Business Research
Source: Jake VanderPlas (2016), Python Data Science Handbook Essential Tools for Working with Data, Oโ€™Reilly Media. 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)
Find elsewhere
๐ŸŒ
Python Data Science Handbook
jakevdp.github.io โ€บ PythonDataScienceHandbook โ€บ 02.01-understanding-data-types.html
Understanding Data Types in Python | Python Data Science Handbook
Remember that unlike Python lists, NumPy is constrained to arrays that all contain the same type. If types do not match, NumPy will upcast if possible (here, integers are up-cast to floating point):
๐ŸŒ
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 - # Importing the NumPy library and aliasing it as 'np' import numpy as np # Creating a 2-dimensional array 'x' with floating-point values x = np.array([[12.0, 12.51], [2.34, 7.98], [25.23, 36.50]]) # Printing a message indicating the original array elements will be shown print("Original array elements:") # Printing the original array 'x' with its elements print(x) # Printing a message indicating the conversion of float values to integer values print("Convert float values to integer values:") # Converting the floating-point values in the array 'x' to integer values using astype(int) # Printing the array obtained after conversion print(x.astype(int))
๐ŸŒ
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.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.3 โ€บ reference โ€บ generated โ€บ numpy.arange.html
numpy.arange โ€” NumPy v2.3 Manual
>>> np.arange(0, 5, 0.5, dtype=int) array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) >>> np.arange(-3, 3, 0.5, dtype=int) array([-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) In such cases, the use of numpy.linspace should be preferred. The built-in range generates Python built-in integers that have arbitrary size, while numpy.arange produces numpy.int32 or numpy.int64 numbers.
๐ŸŒ
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 - Initialize an array of ones using np.ones. Introduce a dtype argument, set to np.int, to ensure that the ones are of NumPy integer type. Note that scikit-learn expects np.float arguments in arrays. The dtype refers to the type of every element in a NumPy array.
Authors: Julian AvilaTrent Hauck
Published: 2017
Pages: 374
๐ŸŒ
Milliams
milliams.com โ€บ courses โ€บ intro_numpy โ€บ NumPy arrays.html
NumPy arrays - Introduction to NumPy
Another important way in which NumPy arrays differ from Python lists is that each array can only hold one "type" of data. The main reason for this is because it's how NumPy is able to perform calculations so quickly. If it knows in advance that all the items in an array are, for example, integers, then it can make some assumptions which make anything you do to it faster.
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ array
NumPy array()
import numpy as np arr = np.array([1.5, 2.5, 3.5], dtype=np.int32) This example creates a one-dimensional array with specified data type int32, converting all floating-point numbers to integers.
๐ŸŒ
APXML
apxml.com โ€บ courses โ€บ essential-numpy-pandas โ€บ chapter-2-getting-started-numpy-arrays โ€บ creating-arrays-from-lists
Creating Arrays from Python Lists
This is the N-dimensional array we discussed. NumPy automatically inferred the data type of the elements. Since all elements were integers, the resulting array has a dtype of int64 (the exact integer type, like int32 or int64, might vary slightly depending on your system).
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ stable โ€บ user โ€บ basics.types.html
Data types โ€” NumPy v2.5 Manual
Generally, problems are easily fixed by explicitly converting array scalars to Python scalars, using the corresponding Python type function (e.g., int, float, complex, str).