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:
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:
- 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:
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:
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:
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:
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:
Code:
import numpy as nump
arrr3 = nump.arange(0, 10, 3)
print(arrr3)
Output:
Code:
import numpy as nump
arrr3 = nump.arange(0, 10, 4)
print(arrr3)
Output:
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:
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:
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:
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:
Tile():
Code:
import numpy as nump
arrr3 = [0,2,3]
print(nump.tile(arrr3, 4))
Output:
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:
Utilizing identity():
Code:
import numpy as nump
equal_matrix = nump.identity(4)
print(equal_matrix)
Output:
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:
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:
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:
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:
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:
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:
Code:
import numpy as nump
arrr = nump.array([1,2,3,4])
arrr2 = nump.append(arrr, [5,6,7])
print(arrr2)
Output:
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:
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:
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:
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 –
40 Online Courses | 13 Hands-on Projects | 215+ Hours | Verifiable Certificate of Completion
4.8
View Course
Related Courses