Numpy data Types Last Updated : 23 Jan, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report NumPy is a powerful Python library that can manage different types of data. Here we will explore the Datatypes in NumPy and How we can check and create datatypes of the NumPy array. DataTypes in NumPyA data type in NumPy is used to specify the type of data stored in a variable. Here is the list of characters available in NumPy to represent data types.CharacterMeaningbBooleanfFloatmTime DeltaOObjectUUnicode StringiIntegeruUnsigned IntegercComplex FloatMDateTimeSStringVA fixed chunk of memory for other types (void)The list of various types of data types provided by NumPy are given below:Data TypeDescriptionbool_Boolean int_Default integer type (int64 or int32)intcIdentical to the integer in C (int32 or int64)intpInteger value used for indexingint88-bit integer value (-128 to 127)int1616-bit integer value (-32768 to 32767)int3232-bit integer value (-2147483648 to 2147483647)int6464-bit integer value (-9223372036854775808 to 9223372036854775807)uint8Unsigned 8-bit integer value (0 to 255)uint16Unsigned 16-bit integer value (0 to 65535)uint32Unsigned 32-bit integer value (0 to 4294967295)uint64Unsigned 64-bit integer value (0 to 18446744073709551615)float_Float valuesfloat16Half precision float valuesfloat32Single-precision float valuesfloat64Double-precision float valuescomplex_Complex valuescomplex64Represent two 32-bit float complex values (real and imaginary)complex128Represent two 64-bit float complex values (real and imaginary)Checking the Data Type of NumPy ArrayWe can check the datatype of Numpy array by using dtype. Then it returns the data type all the elements in the array. Python import numpy as np # Create a NumPy array arr = np.array([1, 2, 3, 4, 5]) # Check the data type of the array data_type = arr.dtype print(data_type) Outputint64 Create Arrays With a Defined Data TypeWe can create an array with a defined data type by specifying "dtype" attribute in numpy.array() method while initializing an array. Python import numpy as np arr1 = np.array([1, 2, 3, 4], dtype=np.float64) # Creating a 3x3 int32 array of zeros arr2 = np.zeros((3, 3), dtype=np.int32) # Creating a 2x2 complex128 array of ones arr3 = np.ones((2, 2), dtype=np.complex128) # Creating a 1D bool array arr4 = np.empty((4,), dtype=np.bool_) # Print the arrays and their data types print(arr1.dtype) print(arr2.dtype) print(arr3.dtype) print(arr4.dtype) Outputfloat64 int32 complex128 bool Convert Data Type of NumPy ArraysWe can convert data type of an arrays from one type to another using astype() function. Python import numpy as np arr1 = np.array([1.2, 2.5, 3.7]) # Converting to int32 arr2 = arr1.astype(np.int32) # Print new array and its type print(arr2) print(arr2.dtype) Output[1 2 3] int32 Comment More infoAdvertise with us Next Article Numpy data Types S sagar99 Follow Improve Article Tags : Numpy Python-numpy Similar Reads Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact 12 min read 3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power 13 min read Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and 9 min read What is Vacuum Circuit Breaker? A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac 13 min read Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca 7 min read CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi 6 min read Python Variables In Python, variables are used to store data that can be referenced and manipulated during program execution. A variable is essentially a name that is assigned to a value. Unlike many other programming languages, Python variables do not require explicit declaration of type. The type of the variable i 6 min read Spring Boot Interview Questions and Answers Spring Boot is a Java-based framework used to develop stand-alone, production-ready applications with minimal configuration. Introduced by Pivotal in 2014, it simplifies the development of Spring applications by offering embedded servers, auto-configuration, and fast startup. Many top companies, inc 15+ min read Like