Python Numpy Tutorial - ones vs ones_like (np.ones vs np.ones_like)

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.





The creator studies Applied and Computational Mathematics at BYU (BYU ACME program)

ONES vs ONES_LIKE

This video will compare ones vs ones like

We import numpy and I’m making a random matrix A. It will be 3 by 2.

So that means 3 rows and 2 columns.

To do ones_like function we need to reference another matrix that is why we created A. It will make a matrix of the same size but fill it with ones

As you can see it is also 3 by 2

Here is the matrix B for comparison.

There you have it, that is the difference between numpy ones and numpy ones_like in python

#PythonMarathon #LearnPython #PythonTutorial
Рекомендации по теме
Комментарии
Автор

'ones' take the size while 'ones_like' take array

sumanpalisetty