Python Data Analysis Example


Introduction to Python Data Analysis Example

The following article provides an outline for Python Data Analysis Example. Python data analysis is defined as, it is the process of rinsing, altering, and forming the data to find helpful information for determining the business. The main aim of the data analysis is to bring out meaningful information from the data and win the decision which also depends on the data analysis. A very easy example of data analysis is, at any point when we grip any decision on in our day-to-day life by analyzing what comes out previously or what will occur by selecting the specific decision. We can say that it not only analyzes the past or future but also it can make decisions depending on it.

Overview of Python Data Analysis

Data Analytics is the field in which sensitive datasets have been analyzed in order to obtain a closure concerning the information which they detain. It can be able to locate the pattern in the sensitive data and pull-out valuable information from them. This process has also been utilized for integrating machine learning algorithms, duplication, and mechanical systems. It has four types of data analytics, such as Descriptive analytics, Diagnostic analytics, Predictive Analytics, and Prescriptive analytics.

Descriptive analytics can define the occurrence over time whether the number of aspects is decreasing or increasing. The diagnostic analytics centers on the cause of its happening at an end. Predictive analytics centers on the events which are looking for the upcoming future. Prescriptive analytics designate a plan of action. We can also say that data analytics is beneficial for decision making which can overcome a lot of suppositions. It also provides the business-critical perception into how their marketing campaigns efforts so that it can adjust them for better results. It can also improve customer service by giving businesses an intense view of their clients by serving them a customized customer experience for their needs.

Different Python Data Analysis Example

Given below are the different python data analysis example:

1. Let us see an example of creating a NumPy array.

Code:

import numpy as numpy
arrr1 = numpy.array([2,3,4])
print(arrr1)

Output:

Python Data Analysis Example Numpy

2. Let us see how to generate a 2-dimensional array and examine the shape of an array.

  • 2-Dimensional Array:

Code:

import numpy as nmpy
arrr = nmpy.array([[4,5,6], [7,8,9]])
print(arrr)

Output:

Python Data Analysis Example - Dimensional array

  • Shape of the Array:

Code:

import numpy as nump
arrr = nump.array([[4,5,6], [7,8,9], [10,11,12]])
print(arrr)
print("The shape is 3 row and 3 columns", arrr.shape)

Output:

Python Data Analysis Example- Array Shape

3. Let us see another example of how to retrieve an element from the 2-D array by utilizing the index place.

Code:

import numpy as nump
arrr2 = nump.array([[4,5,6], [7,8,9], [10,11,12]])
print(arrr2[0][2])
print(arrr2[0,2])
print(arrr2[0,-1])
print(arrr2[-1,0])

Output:

Python Data Analysis Example - Retrieve an element

4. Let us now see an example of generating an array that has a type string.

Code:

import numpy as nump
arrr3 = nump.array(['Andhrapradesh', 'Maharashtra', 'Tamilnadu', 'Himachal'])
print(arrr3)

Output:

generating an array that has a type string

Let us see the above code by using an index.

Code:

import numpy as nump
arrr3 = nump.array(['Andhrapradesh', 'Maharashtra', 'Tamilnadu', 'Himachal'])
print(arrr3[2])

Output:

Using an index

5. By utilizing arange() and linspace() function to equally spaced values in a defined intent.

Code:

import numpy as nump
arrr3 = nump.arange(0, 10, 2)
print(arrr3)

Output:

Python Data Analysis Example - Spaced values

Code:

import numpy as nump
arrr3 = nump.arange(0, 10, 3)
print(arrr3)

Output:

Python Data Analysis Example 7

Code:

import numpy as nump
arrr3 = nump.arange(0, 10, 4)
print(arrr3)

Output:

Python Data Analysis Example 8

6. Let us see an example of data analytics for an array of equally spaced numbers within a particular interval.

Code:

import numpy as nump
arrr3 = nump.linspace(0, 20, 30)
print(arrr3)

Output:

spaced numbers within a particular interval

7. Example of generating an array of random values in the middle of 0 and 1, in a provided shape.

Code:

import numpy as nump
arrr3 = nump.random.rand(10)
print(arrr3)
print('n')
arrr3 = nump.random.rand(1,2)
print(arrr3)

Output:

values in the middle of 0 and 1

8. Example of generating an array of constant values in a provided span.

Code:

import numpy as nump
print(nump.full((5,7), 20))

Output:

constant values

9. To copy every element of an array a particular number of times by utilizing the repeat() and tile() functions.

Repeat():

Code:

import numpy as nump
arrr3 = [0,2,5]
print(nump.repeat(arrr3, 4))

Output:

Python Data Analysis Example - Copy every element

Tile():

Code:

import numpy as nump
arrr3 = [0,2,3]
print(nump.tile(arrr3, 4))

Output:

Python Data Analysis Example - Tile function

10. Let us see how to generate a naming matrix utilizing the eye() and identity() functions.

Utilizing eye() function:

Code:

import numpy as nump
equal_matrix = nump.eye(4)
print(equal_matrix)

Output:

Python Data Analysis Example Matrix

Utilizing identity():

Code:

import numpy as nump
equal_matrix = nump.identity(4)
print(equal_matrix)

Output:

Python Data Analysis Example - Utilizing identity()

11. Let us see another example to generate a 5×5 2D array for random numbers within 0 and 1.

Code:

import numpy as nump
arrr3 = nump.random.rand(5,5)
print(arrr3)

Output:

Python Data Analysis Example - 2D array

12. Example of calculating the mean, median, standard deviation, and variance.

Code:

import numpy as nump
arrr3 = [0, 2, 3]
print(nump.mean(arrr3))
print(nump.median(arrr3))
print(nump.std(arrr3))
print(nump.var(arrr3))

Output:

Python Data Analysis Example Calculations

13. Example to add an array next to the column.

Code:

import numpy as nump
arrr3 = [0, 2, 3]
print(nump.sum(arrr3, axis=0))

Output:

Python Data Analysis Example - Add an Array

14. Example of sorting an array next to the row by utilizing the sort() function.

Code:

import numpy as nump
arrr3 = nump.random.rand(5,5)
print(arrr3)

Output:

Utilizing the sort() function

15. Example of sorting element next to the row.

Code:

import numpy as nump
arrr3 = nump.random.rand(5,5)
print(nump.sort(arrr3, axis=1))

Output:

Python Data Analysis Example - Sorting Element

Example to add an element to an array by utilizing the append() function. Let us see how to add an element to an array:

Code:

import numpy as nump
arrr = nump.array([4,5,6,7])
arrr1 = nump.append(arrr, 8)
print(arrr1)

Output:

Add an element to an array

Code:

import numpy as nump
arrr = nump.array([1,2,3,4])
arrr2 = nump.append(arrr, [5,6,7])
print(arrr2)

Output:

Add an element to an array 2

16. Example of deleting multiple elements in an array.

Code:

import numpy as nump
arrr = nump.array([1,2,6,8,7,9,11])
print(arrr)
print('n')
arrr3 = nump.delete(arrr, [1,5])
print(arrr3)

Output:

deleting multiple elements in an array

17. Example of combining the elements from two arrays.

To combine an array, it will first combine and split and then combine the array items by column.

Code:

import numpy as nump
arrr1 = nump.array([[1,2,3,4], [4,5,6,7]])
arrr2 = nump.array([[7,8,9,10], [11,12,13,14]])
cat = nump.concatenate((arrr1,arrr2), axis=0)
print(cat)

Output:

elements from two array

18. Example of concatenating an array item by row.

Code:

import numpy as nump
arrr1 = nump.array([[1,2,3,4], [4,5,6,7]])
arrr2 = nump.array([[7,8,9,10], [11,12,13,14]])
cat = nump.concatenate((arrr1,arrr2), axis=1)
print(cat)

Output:

concatenating an array item by row

Conclusion

In this article, we conclude that python is the programming language that can be used by data analysts to extract complicated data and also to find out useful information from it. We have also seen the overview of the data analysis, and also the top different python data analysis examples.

Recommended Articles

This is a guide to Python Data Analysis Example. Here we discuss the introduction and top different python data analysis examples. You may also have a look at the following articles to learn more –

  1. Python Pillow
  2. Sort Dictionary in Python
  3. Merge Dictionaries in Python
  4. List of Dictionary in Python

The post Python Data Analysis Example appeared first on EDUCBA.



Source link

Leave a Reply

Your email address will not be published.