Page 446 - AI Ver 3.0 class 10_Flipbook
P. 446

NumPy (Numerical Python)

              NumPy is a powerful open-source scientific package that stands for 'Numerical Python'. It uses mathematical
              and logical operations for handling large datasets through powerful data structure-n-dimensional arrays that
              also speeds up data processing. NumPy is the first step in learning, to become a Python data scientist in the
              future. Various other libraries like Pandas, Matplotlib, and Scikit-learn are built on using some concepts of this
              magical library. It can also be easily interfaced with other Python packages and provides tools for integrating
              with other programming languages like C, C++ etc.
              If you are using basic Python installed through https://www.python.org website then the NumPy package is not
              included by default. You need to install it separately.
              NumPy can be installed by typing following command:

                                                         pip install NumPy
              Once it is installed, it can be readily used in any Python code by using import keyword as shown below:
              Numpy can also be imported into the Jupyter Notebook by using the given statement:

              import numpy                               # this will import the complete numpy package
              OR
              import numpy as npy                        # this will import numpy and referred as npy
              OR
              from numpy import array                    #this will import ONLY arrays from whole numy package

              OR
              from numpy import array as ary     #this will import ONLY arrays and referred as ary

              Arrays


              Arrays are an ordered collection of values of the same data type that can be arranged in one or more dimensions.
              They can store numbers, characters, Boolean values, etc. The elements are referred to using index numbers
              (positions) that start from 0. Almost all programming languages support arrays in one form or another.

                 • A one-dimensional array is called a Vector.
                 • A two-dimensional array is called a Matrix.
                 • An array with multiple dimensions is called an n-dimensional array.
              In NumPy, we can  create  n-dimensional arrays,  which are  considered  an  alternative  to Python  lists  because
              they allow faster access to reading and writing elements efficiently. The NumPy library provides a large set of built-
              in functions in the form of modules and packages for creating, manipulating, and transforming NumPy arrays.

              NumPy Arrays vs Python Lists

              The difference between NumPy Arrays vs Python Lists is shown in the below table:

               Feature              NumPy Array                               Python List
               Data Type            Homogeneous (stores elements of the  Heterogeneous (can store elements of
                                    same type)                                different types)
               Data Type            Does not support mixed types within the  Supports mixed types and allows implicit
               Conversion           same array                                conversion
               Memory Efficiency    More memory-efficient                     Occupies more memory


                    444     Touchpad Artificial Intelligence (Ver. 3.0)-X
   441   442   443   444   445   446   447   448   449   450   451