What is np.array() in Python
The Numpy array object in Numpy is called ndarray. We can create ndarray using numpy.array() function. It is used to convert a list, tuple, etc. into a Numpy array.
Syntax: numpy.array(object, dtype=None)
Creating a NumPy array using the .array() function.
Python3
# importing numpy module import numpy as np # creating numpy array res = np.array([ 'G' , 'F' , 'G' ]) print ( "Numpy Array in python :" , res) print ( type (res)) |
Output:
Numpy Array in python : ['G' 'F' 'G'] <class 'numpy.ndarray'>
Difference between Numpy array and Numpy matrix
While working with Python many times we come across the question that what exactly is the difference between a numpy array and numpy matrix, in this article we are going to read about the same.
Contact Us