Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

NumPy stands for Numerical Python.

It is a Python library for scientific


computing and data analysis. NumPy provides support for large,
multi-dimensional arrays and matrices, along with a large collection of
mathematical functions to operate on these arrays.

NumPy provides an easy-to-use interface for performing operations on


arrays, such as element-wise arithmetic, matrix multiplication, reshaping,
slicing, and indexing. It also provides functionality for linear algebra,
Fourier transforms, and random number generation, among other things.

NumPy is widely used in various fields such as science, engineering,


finance, and data science, and is considered to be one of the fundamental
libraries for scientific computing in Python.

Data analytics is the process of examining and analyzing large and complex data sets
to extract useful insights and knowledge that can help in making informed decisions. In
this process, various statistical and computational techniques are used to transform,
clean, and process raw data into meaningful insights.

Types of Data:

There are two types of data: qualitative and quantitative data. Qualitative data is
descriptive and non-numerical data that is difficult to measure, such as opinions,
attitudes, and behaviors. On the other hand, quantitative data is numerical data that can
be measured and analyzed, such as height, weight, income, and sales figures.

Importance of Data:

Data is essential in decision-making because it helps in identifying patterns, trends, and


relationships in the business environment. It also helps in tracking performance,
forecasting trends, and identifying opportunities and threats.

Data Analysis Vs Data Analytics:


Data analysis is a process of examining data using statistical and computational
techniques to draw conclusions or insights from the data. Data analytics, on the other
hand, is a broader term that includes data analysis as a subset, but also involves using
machine learning and other advanced techniques to analyze data.

Types of Data Analytics:

1. Descriptive Analytics: It involves analyzing historical data to understand trends


and patterns.
2. Diagnostic Analytics: It involves analyzing data to determine why something
happened or to identify the root cause of a problem.
3. Predictive Analytics: It involves analyzing data to predict future events or trends.
4. Prescriptive Analytics: It involves analyzing data to recommend actions that can
optimize performance or solve a problem.

Elements of Analytics:

The four main elements of analytics are data, tools, people, and processes. These
elements work together to help organizations make informed decisions based on data
insights.

Data Analysis Process:

The data analysis process involves several steps, including data collection, data
cleaning, data transformation, data modeling, data visualization, and data interpretation.

Qualitative and Quantitative Analyses:

Qualitative analysis involves analyzing non-numerical data, such as text, images, and
videos. It involves identifying patterns, themes, and concepts in the data. Quantitative
analysis involves analyzing numerical data using statistical techniques, such as
regression analysis and hypothesis testing.

Open Source Data:


Open source data is data that is freely available and accessible to anyone. It includes
data from various sources, such as government agencies, research institutions, and
private organizations. Open source data is becoming increasingly popular in data
analytics because it provides a vast amount of data that can be used for analysis and
research.

NumPy (Numerical Python) is a popular open-source library for scientific computing in


Python. It provides a powerful N-dimensional array object, tools for integrating C/C++
and Fortran code, and useful linear algebra, Fourier transform, and random number
capabilities.

Installation:
NumPy can be installed using pip, which is a package installer for Python. Simply open
your command prompt or terminal and type "pip install numpy". This will install the
latest version of NumPy on your system.
Ndarray:
The ndarray is the most important object in NumPy. It is a multidimensional array of
elements, all of the same type, indexed by a tuple of positive integers. It can be created
using the numpy.array() function.

Creating an array:
We can create a NumPy array by passing a list or tuple to the numpy.array() function.

import numpy as np

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


print(arr)

This will output: [1 2 3 4 5]

Intrinsic creation of an array:

NumPy also provides several intrinsic functions for creating arrays of different shapes
and sizes. Some of the commonly used intrinsic functions are:

● np.zeros(): Creates an array of zeros with the specified shape.


● np.ones(): Creates an array of ones with the specified shape.
● np.eye(): Creates an identity matrix of the specified size.
● np.arange(): Creates an array of evenly spaced values between the start and end
values.
● np.random.rand(): Creates an array of random values between 0 and 1 with the
specified shape.

Data types:
NumPy arrays can hold elements of different data types, such as integers, floating-point
numbers, and complex numbers. The dtype parameter can be used to specify the data
type of the array.

import numpy as np

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


print(arr)

This will output: [1. 2. 3. 4. 5.]


Basic operations:
NumPy provides several basic arithmetic operations that can be performed on arrays.
These include addition, subtraction, multiplication, division, and more

import numpy as np

arr1 = np.array([1, 2, 3])


arr2 = np.array([4, 5, 6])

print(arr1 + arr2)
print(arr1 - arr2)
print(arr1 * arr2)
print(arr1 / arr2)

[5 7 9]
[-3 -3 -3]
[ 4 10 18]
[0.25 0.4 0.5 ]

Aggregate functions:
NumPy provides several aggregate functions that can be used to perform operations on
arrays, such as finding the sum, mean, median, maximum, minimum, and more.
import numpy as np

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

print(np.sum(arr))
print(np.mean(arr))
print(np.median(arr))
print(np.max(arr))
print(np.min(arr))

15
3.0
3.0
5
1

Indexing, slicing, and iterating:

NumPy arrays can be indexed and sliced just like Python lists. Iterating through a
NumPy array can be done using a for loop.

import numpy as np

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

print(arr[0]) # output: 1
print(arr[1:3]) # output: [2 3]

Conditions and Boolean arrays:


NumPy arrays can be compared with scalar values or other arrays to create Boolean
arrays. These Boolean arrays can then be used to select elements from the original
array

import numpy as np

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


print(arr > 3) # output: [False False False True True]
print(arr[arr > 3]) # output: [4 5]

Array manipulation:

NumPy provides several functions for manipulating arrays, such as joining, splitting,
shape changing, sorting, and more.

Joining:

Arrays can be joined using the numpy.concatenate() function.

import numpy as np

arr1 = np.array([1, 2, 3])


arr2 = np.array([4, 5, 6])

print(np.concatenate((arr1, arr2)))

Intrinsic creation of an array:


NumPy also provides several functions for intrinsic creation of arrays. For example, to
create an array of zeros, we can use the numpy.zeros() function as shown below:

import numpy as np

a = np.zeros((2, 3))
print(a)

[[0. 0. 0.]

[0. 0. 0.]]

Iterating over arrays:


We can iterate over NumPy arrays using a for loop. For example, to iterate
over the elements of a 1-dimensional array, we can use the following code:
```python
import numpy as np

a = np.array([1, 2, 3])

for x in a:
print(x)

Array manipulation:

NumPy provides several functions for array manipulation, such as joining, splitting,
shape changing, and sorting.

Joining:

We can join two or more arrays using the numpy.concatenate() function. For example,
to join two 1-dimensional arrays, we can use the following code:

import numpy as np

a = np.array([1, 2, 3])

b = np.array([4, 5, 6])

c = np.concatenate((a, b))

print(c)

[1 2 3 4 5 6]
Splitting:

We can split an array into two or more arrays using the numpy.split() function. For
example, to split a 1-dimensional array into two arrays, we can use the following code:

import numpy as np

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

b = np.split(a, 2)

print(b)

[array([1, 2, 3]), array([4, 5, 6])]

Shape changing:

We can change the shape of an array using the numpy.reshape() function. For example,
to reshape a 1-dimensional array into a 2-dimensional array, we can use the following
code:

import numpy as np

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

b = np.reshape(a, (2, 3))

print(b)

[[1 2 3]

[4 5 6]]

Sorting:

We can sort the elements of an array using the numpy.sort() function. For example, to
sort the elements of a 1-dimensional array in ascending order, we can use the following
code:
import numpy as np

a = np.array([3, 2, 1])

b = np.sort(a)

print(b)

[1 2 3]

You might also like