Coding skills here for learning
5 subscribers
266 photos
3 files
10 links
Download Telegram
obj_explore(a,'public')

exploration
# Assigning elements of an array
z[1,0] = -1
z[2] = [4,5,7] # assign whole row from a list
z[:,0] = np.array([4.2,5.2,6.2,7.2,8.2]) # assign column from nparray
z[:2,1]=9.3
z[3][1]=-2 # note double bracket indexing
print(z)
print(b)
print(b*b) # element by element
print(c*c) # matrix multiplication

when multipying the ndarray you can do it one by one but with matrix you can not but exclusions there is when multipying you can use .transpose() to multiply one by one in matrix
a = np.empty(25,'float64') # not initialized !
b = np.zeros(5) # initialized with zeros
c = np.ones(5)
d = np.arange(10)
e = np.linspace(2, 3, 100) # fill between 2 and 3 with 10 points
print(a,b,c,d,e,sep='\n\n')


empty random 25 numbers with float 64 type

np.zeros(10) with filling out the 10 zeros

np.ones(5) makes filling with 5 ones

arrange you can do (from x, to y)
linspace(from x, to y, with 100 parts)
z = np.linspace(0, 2, 15)
z = np.reshape(z,[5,3])

with linespace and reshaping
z = np.linspace(0, 2, 12)
z = np.reshape(z,[4,3])
print(z,end='\n\n')

with reshape and use end = \n\n
mask = np.logical_and(z>1.0,z<1.75)

logical_and is equal to AND
x = np.arange(3) + 5
y = np.ones((3,3))
print(x,y,x+y,sep='\n\n')
fig, ax = plt.subplots() work with this
plt.bar(x_indexes - width, dev_y, width = width, color = 'k', label = 'All Devs')

bor bar plot using first x and y then proper width then color then label we have linestyle and linewidth alpha
shadow = True, autopct= '%1.1f%%' for percentage explode= explode, startangle=90,




slices = [120, 80, 30, 20]
labels = ['Sixty', 'Fourty', 'Extral', 'Extra2']
colors = ['blue', 'red', 'yellow', 'green']
explode = [0 , 0 , 0.1, 0]
labels = ['player1', 'player2', 'player3']
colors = ['#008fd5', '#fc4f30', '#6d904f']
plt.stackplot(minutes, player1, player2, player3, labels = labels, colors= colors)
plt.legend(loc = 'lower left')
plt.title("My Awesome Stack Plot")
plt.tight_layout()
plt.show

matplotlib with
ages = [18,19,21,25,26,26,30,32,38,45,55]
bins = [10,20,30,40,50,60]

median_age = 29

color = '#fc4f30'

plt.hist(ages, bins=bins, edgecolor='black', log=True, alpha = 0.5, label = 'Age Median')

plt.grid(True)

# plt.axvline(median_age, color = color, label = 'Age Median')
plt.legend()
plt.title('Ages of Respondents')
plt.tight_layout()
plt.style.use('seaborn')
x = [5,7,8,5,6,7,9,2,3,4,4,4,2,6,3,6,8,6,4,1]
y = [7,4,3,9,1,3,2,5,2,4,8,7,1,6,4,9,7,7,5,1]

colors = [7,5,9,7,5,7,2,5,3,7,1,2,8,1,9,2,5,6,7,5]
sizes = [209,486,381,255,191,315,185,228,174,538,239,394,399,153,273,293,436,501,397,539]

plt.scatter(x, y, s=sizes, c=colors, cmap = 'Greens', marker = 'o', edgecolor= 'black', linewidth = 1, alpha = 0.75)



scatter plot
a = np.array([[1,2,3,4,5,6,7],[8,9,10,11,12,13,14]])


a[1, 5]


for finding with index
you can use it with negative indexing
a[0, :] gets all from first row
a[:, 2] means to get from all the rows 3rd number
a[0, 1:6:2] means first row start from 1 end in 6 index stepping with 2