Page 451 - AI Ver 3.0 class 10_Flipbook
P. 451
Type Function Example
Row wise & ARR.
[1]: import numpy as np
column wise min(axis=1)
ARR = np.array([[11,2,13,4],[3,4,5,6]])
minimum value for row print("Rowwise min :",ARR.min(axis=1))
ARR. print("Column wise min :",ARR.min(axis=0))
min(axis=0) Rowwise min : [2 3]
for column Column wise min : [3 2 5 4]
Sum of all values ARR.sum()
[1]: import numpy as np
in the given array
ARR = np.array([[11,2,13,4],[3,4,5,6]])
print("Row Wise sum :",ARR.sum(axis=1))
print("Column wise sum :",ARR.sum(axis=0))
print("sum is :",ARR.sum())
Rowwise sum : [30 18]
Column wise sum : [14 6 18 10]
sum is : 48
Sorting the array ARR.sort()
[1]: a = np.array([12,4,-10,23,29,15, -1,45,33,37,-14])
#Creating a 1-D Numpy array
print(np.sort(a)) #Printing the sorted numpy array
#We can also sort array row wise and column wise!
b = np.array([[-9,5,18,9,12], [10,11,3,-5,-10]])
#Creating a 2-D Numpy array
print(np.sort(b, axis = 1)) #Axis = 1performs the
sorting function row-wise
print(np.sort(b, axis = 0)) #Axis = 0 performs the
sorting function columns-wise
[-14 -10 -1 4 12 15 23 29 33 37 45]
[[ -9 5 9 12 18]
[-10 -5 3 10 11]]
[[ -9 5 3 -5 -10]
[ 10 11 18 9 12]]
Pandas (PANel DAta)
Pandas is an open-source Python library used for data manipulation and analysis. It provides strong features for
working with three key data structures: Series (1-dimensional), DataFrame (2-dimensional), and Index (used for
label-based indexing). These structures allow smooth processing and analysis of data, regardless of its origin. In
Pandas, the data need not be labelled to be placed into a data structure.
Pandas was created by Wes McKinney in 2008. The name "Pandas" is derived from Panel Data (a term in statistics
for multidimensional data) and Python, as it was designed for data analysis in Python.
Pandas is built on top of NumPy, so while you don't need to be an expert in NumPy to use Pandas, familiarity
with NumPy can be helpful when performing operations on data.
Advance Python (Practical) 449

