You are on page 1of 2

#Calculating percentiles

import numpy as np
arr = np.array([71, 92, 82, 97, 74, 68])
# Printing array
print("Data (arr):\n",arr,"\n")# Calculating 20th percentile
res = np.percentile(arr, 20)
print("20th Percentile is:\n",res)
res = np.percentile(arr, 85)# Calculating 85th percentile
print("85th Percentile is:\n",res)
res = np.percentile(arr, 21)# Calculating 21st percentile
print("21st Percentile is:\n",res)

# Calculating mean in an array


import numpy as np
inputArr = [12, 17, 25, 87, 23]
print("inputArray : ", inputArr)
print("Mean of inputArray : ", np.mean(inputArr))# calculate mean of
inputArray'''

#check if numpy array is multidimensional or not


import numpy as np
array = np.array([[[0,8,9,4],[5,6,7,2],[4,8,2,5]],[[7,9,7,0],[6,7,2,8],
[8,7,6,5]]])
print("array:\n",array,"\n")
res = array.ndim
print("Result:\n",res,"\n")

You might also like