Python Tutorial - Python Numpy Array Multiplication

preview_player
Показать описание


This is a Python anaconda tutorial for help with coding, programming, or computer science. These are short python videos dedicated to troubleshooting python problems and learning Python syntax. For more videos see Python Help playlist by Rylan Fowers.





In python we will import numpy as np

parentheses, bracket to start the matrix, then another bracket to enter the first row. After each row close with a bracket. At the end close the entire matrix with one more bracket and finally close your parentheses

This is what the array will look like when you print it out

We will save this 3x3 array as x

Here we are reshaping our x matrix to be a one long matrix that is 1 row by 9 columns

This is important to do sometimes because In matrix multiplication, the dimensions need to line up. An easy way to remember how to know if the dimensions will work is to look at the number of columns of the first matrix (or second dimension number) and the number of rows of the second matrix (or first dimension number). Those numbers need to be the same for it to work

Now I have defined a y matrix so we can see multiplication.

Notice the x is shaped (3,3) and the y is (3,2) since 3=3 we can do this multiplication, but only if we do x first then y

To multiply you can use the @ symbol.

There you have it, that is how you multiply matrices or arrays in python

#PythonMarathon #LearnPython #PythonTutorial Learn Python:

Video Equipment:

Other:
Рекомендации по теме
Комментарии
Автор

clear and with no BS. you rock, thank you!

mirapaws
Автор

SPOILER ALERT: array multiplication is not same as matrix multiplication

EJRoy
Автор

I know how you got the answer using "analogue" method, as it were, but can you please explain for a beginner how whaat you have done works in python

BN-hynd
Автор

# i am struggling to get printed the maximum value from the result .
could you please help me?

def khalid():

li = database1
mp = database2

for i in range(1, len(li)):
if i > 0:
for p in range(1, len(mp)):
if p > 0:
sr = pd.Series(li[i]-mp[p-1])

result = sr[[sr.idxmax()]]
print ([result])
khalid()

khalidwithyoutub