Descargar el Código: patreon.com/pythonmaraton
Join Patreon: patreon.com/pythonmaraton
^Downloadable code & more! np.roll
So here we have a random array A that I created earlier.
np.roll is a numpy function that allows you to shift arrays by as many indexes as you desire. Let’s jump into this example and show you how this works.
np.roll(A,1) Now the 1 is in the 10 spot the 10 is in the three spot and so on… As you can see everything has been shifted over to the right by one.
Next let’s see A again. And lets do np.roll but this time we will shift it by two.
Now you might be wondering Why is this useful?
Let me go ahead and show you an application.
Suppose you have an array of points and you want to approximate the derivative or in other words the step at each point. np.roll can help you do that.
We just take A and subtract all the points shifted to the right by one or in other words A - np.roll(A,1)
Now make sure to ignore the first term. If we are finding the difference in 25 points then there will only be 24 differences .
The first term is the difference between the first and last point so it is not significant step. So I like to use the (A - np.roll(A,1))[1:]
So there you have it that is how to use numpy’s np.roll function in python.
Please check out some of my other python videos and don’t forget to hit subscribe :D
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.
✅Subscribe: https://www.youtube.com/channel/UCub4...
📺Channel: https://www.youtube.com/channel/UCub4...
▶️Watch Latest Python Content: https://www.youtube.com/watch?v=myCPg...
▶️Watch Latest Other Content: https://www.youtube.com/watch?v=2YfQs...
🎵Theme Music: https://www.bensound.com/royalty-free...
#PythonMarathon #LearnPython #PythonTutorial
Nesta página do site você pode assistir ao vídeo on-line Python Tutorial - Python Numpy Roll (np.roll) duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Python Marathon 18 Julho 2019, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 3,914 vezes e gostou 45 espectadores. Boa visualização!