Open In App
Related Articles

Data Analysis with Python

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

In this article, we will discuss how to do data analysis with Python. We will discuss all sorts of data analysis i.e. analyzing numerical data with NumPy, Tabular data with Pandas, data visualization Matplotlib, and Exploratory data analysis.

 Data Analysis With Python 

Data Analysis is the technique of collecting, transforming, and organizing data to make future predictions and informed data-driven decisions. It also helps to find possible solutions for a business problem. There are six steps for Data Analysis. They are: 

  • Ask or Specify Data Requirements
  • Prepare or Collect Data
  • Clean and Process
  • Analyze
  • Share
  • Act or Report
Data Analysis with python

Data Analysis with Python 

Note: To know more about these steps refer to our Six Steps of Data Analysis Process tutorial. 

Analyzing Numerical Data with NumPy

NumPy is an array processing package in Python and provides a high-performance multidimensional array object and tools for working with these arrays. It is the fundamental package for scientific computing with Python.

Arrays in NumPy

NumPy Array is a table of elements (usually numbers), all of the same types, indexed by a tuple of positive integers. In Numpy, the number of dimensions of the array is called the rank of the array. A tuple of integers giving the size of the array along each dimension is known as the shape of the array. 

Creating NumPy Array

NumPy arrays can be created in multiple ways, with various ranks. It can also be created with the use of different data types like lists, tuples, etc. The type of the resultant array is deduced from the type of elements in the sequences. NumPy offers several functions to create arrays with initial placeholder content. These minimize the necessity of growing arrays, an expensive operation.

Create Array using numpy.empty(shape, dtype=float, order=’C’)

Python3




import numpy as np
  
b = np.empty(2, dtype = int)
print("Matrix b : \n", b)
  
a = np.empty([2, 2], dtype = int)
print("\nMatrix a : \n", a)
  
c = np.empty([3, 3])
print("\nMatrix c : \n", c)


Output:

Empty Matrix using pandas

Empty Matrix using pandas 

Create Array using numpy.zeros(shape, dtype = None, order = ‘C’)

Python3




import numpy as np
  
b = np.zeros(2, dtype = int)
print("Matrix b : \n", b)
  
a = np.zeros([2, 2], dtype = int)
print("\nMatrix a : \n", a)
  
c = np.zeros([3, 3])
print("\nMatrix c : \n", c)


Output:

Matrix b : 
 [0 0]

Matrix a : 
 [[0 0]
 [0 0]]

Matrix c : 
 [[0. 0. 0.]
 [0. 0. 0.]
 [0. 0. 0.]]

Operations on Numpy Arrays

Arithmetic Operations

  • Addition: 

Python3