What Is Numpy In Python

 What Is Numpy In Python

 
NumPy is the package privided by Python for scientific computing.In Data Analaytics the basic fundamental theory relires upon on the analysis of the data.Here th Numpy package of Python place a very significant role to perform the various inbuild mathematical functions for data.Numpy is basically a Python library that works on the concept of Array frame of data.With the Numpy functionality you can work on a multidimensional array object and also on various derived objects (such as masked arrays and matrices).When the data is in array form then with the Numpy function you can perform the below imprtant operation on the Data Array object.

    1.Different Mathematical Operations like sum,multiplication etc
    2.Different logical operations like  And/OR logical operations
    3.Shape Manipulation of the Array Object
    4.Sorting of the data
    5.Basic Linear Algebra
    6.Basic Statistical Operations
    7.Random Simulation and much more



Now Let's see trhe different operations that can be easily performed by Numpy pacakage in Python

In Numpy all the data elements are stored as form of object and the array object is called as ndarray


How To Import Numpy:

To use the Numpy package you have to simpy write the statement

Import Numpy

With the Import Numpy statement you are basically importing Numpy package for using it's in built functionalities and features.Without importing the Numpy package you can not use the Numpy package's features and functionalities

How To Create a Numpy Ndarray Object 

Now let's look at the process of creating a Ndarray object with the Numpy package.

You have to basically use the array() function to create the ndarray object.

Lets' have a look at the example below for this.

Example

import numpy as np

arr = np.array([1, 2, 3, 4, 5])

print(arr)

print(type(arr))

Here we are creating the array as arr and storing the values in the array with the np.array function.

At last we are printing the array value which arr and the type of the array

Below is the output of this above program

[1 2 3 4 5]
<class 'numpy.ndarray'>
In the first line it is printing the value which is stored in the arr object

In the second line it is printing the type of arr which is a ndarray type of object


Like you work with array type object using the Numpy package in the same way you can wotrk with List,Tuple also with the Numpy Packages

Now let's understand the concepts of List and Tuple

What Is Tuple In Python

Tuple is a collection of data seperated by comma.

To create a tuple you have to use the () operator to enclose the values in the tuple with the ,

Take a look at the tuple below

Games = ("Cricket","Football","Tennis")

 print(Games)

Output:

('Cricket','Football','Tennis')

So you can see in the above example you are storing the different types of Games values as  the form of Tuple and finally you are printing the Tuple value which is Games

Here we are not covering more on Tuples and this will be covered in another post

What is List In Python:

A list is a data structure in Python that is a mutable, or changeable, ordered sequence of elements. Each element or value that is inside of a list is called an item. Just as strings are defined as characters between quotes, lists are defined by having values between square brackets [ ].

List basically contanis same type of data.With the help of list you can perform the same types of operation on the same type of data.

If you want to keep different types of car manufacturers then we can use list to keep the details as these all are same kind of data

Car_Manufacturers = ['Honda', 'Toyota', 'BMW', 'Hyundai', 'Audi']

When we print out the list, the output responds exactly like the list we created:

print(Car_Manufacturers)

Output

['Honda', 'Toyota', 'BMW', 'Hyundai', 'Audi']

Basic Difference Between Tuple And List

Tuple is immutable that means you can not manipulate or change the data of Tuple.But List is mutable that means the data in Lists are changable

In this lesson you have mainly learned how to store and print data in the Array,List and Tuple format and how you can print the data.

More lesson to come with the in depth features and functionalites of Numpy

Comments