Ultimate Guide to NumPy Arrays - VERY DETAILED TUTORIAL for beginners!
HTML-код
- Опубликовано: 9 май 2024
- In this tutorial, we will learn about NumPy arrays in great detail! 🤓
NumPy is one of the most popular Python libraries and just as it sounds - it deals with numbers!
An array, on the other hand, is a collection of items of the same type and it's the data structure that NumPy uses.
This video will give you the tools and demos to understand how NumPy manages data and how it approaches memory consumption.
We will explore different functions and methods to:
⭐ create N-dimensional arrays
⭐ reshape arrays
⭐ sort arrays with different algorithms
⭐ filter and manipulate array values
The goal of this Ultimate Guide (and all the future Ultimate Guides I'll be filming for other libraries) - is to cover a HUGE part of the NumPy documentation. It's meant for all the folks who learn by example rather than by reading dry text and hopefully this will take your NumPy skills to an expert level! 🥼🥼🥼
You can find PART 2 of this tutorial here: • NumPy Operations - Ult...
If you don't feel like coding along with me, you can always clone my code from Wayscript!
It's the IDE I'm using in this video, and if you like what you see - you can sign up for free!! 😀
⭐ get complete tutorial code:
* Sorry code is unavailable, RIP Wayscript 😭😭😭*
⭐ what is Wayscript?
wsxdocs.wayscript.com/
🛠️ Related Tutorials of Mine 🛠️
__________________________________________
⭐ PART 2 of NumPy The Ultimate Guide:
• NumPy Operations - Ult...
⭐ Convert Binary to Decimal Like a Pro:
• Binary to Decimal - Co...
⭐ Train Basic Neural Network with NumPy and Pandas:
• Train Basic Neural Net...
⭐ Python Learning Roadmap:
• Python Learning Roadma...
⭐ Anaconda Guide for Beginners:
• Anaconda Beginners Gui...
⏲️ TIME STAMPS ⏲️
__________________________________________
00:00 - intro
00:43 - install NumPy
01:02 - import NumPy
01:09 - create an array with NumPy arange
04:09 - create an array with NumPy array
04:27 - why arrays are better than lists
07:08 - NumPy data types
08:06 - 2 dimensional arrays
09:47 - shape attribute
10:38 - reshape arrays
12:33 - create empty arrays
14:14 - NumPy eye function
15:10 - change array values
18:41 - sort NumPy arrays
21:13 - difference between copy and view
23:50 - next NumPy tutorial and thank you for watching!
🐍 Install with Anaconda 🐍
__________________________________________
conda install -c anaconda numpy
* more details here: numpy.org/install/
🔗 Important Links 🔗
__________________________________________
⭐ NumPy Documentation:
numpy.org/doc/stable/user/abs...
💳 CREDITS 💳
__________________________________________
⭐ Icons by: flaticon.com
⭐ Text Animations by: mixkit.co
THANK YOU SO MUCH FOR WATCHING! 💗 - Наука
I worked with numpy arrays for some time, i'm still not sure what's the difference between int and uint
This is a great question Sinisa!! 😀
⭐ int reserves one bit to store whether the integer is negative or positive.
⭐ uint, on the other hand, stands for "unsigned integer" so it doesn't track whether the integer is negative or not.
It is assumed to be non-negative, for example: the speed of a motorcycle cannot be negative, therefore it makes more sense to store it as a uint.
So in the case of uint, there is no reserved bit that tracks the sign (sign means either - or +) so it's free to store other data.
In other words, while both int and uint take up the exact same number of bits - unit has the potential to convey larger numbers.
An extremally abstract example:
int is +0001011 (we have 7 available slots to store data, the first bit is reserved)
uint is 00001011 (we have 8 available slots to store data, the first bit is not reserved)
I hope it helps! 😊
@@PythonSimplified thanks, but i don't think floats have u and non u versions, do they store negative sign just as they are?
@@Sinke_100 On noooo!!! you're right, I totally messed up with the u float part!! 😅😅😅
I'm gonna edit it out in the original comment so that folks don't get confused by my mistakes...
I've checked it now in a few threads and it looks like there's no hardware support or real need for it... I always thought it's applicable for both int and float, thanks for teaching me something new! 😊
@@PythonSimplified i just asked 😀 u are more familiar with the topic than me, i used numpy to create images, and i know when i played with it, data types was definetly important when i tryed to save png with 16 bits per channel, and tiffs with even 32 bits per channel, for tiff i had to use float32 as dtype, but i just used what i read on stackoverflow what works, i didn't go depper into why, what i do think i know dtypes are important with numpy cause it is written in c, perhaps you might know more since u probably worked with c, i barely tryed it once, it's really hard
I'm new to numpy. During the video I wandered where I'm really gonna need it. But after reading this comment thread, I found think I found a good usecase.
I love the fact that your style of teaching is simple and straight to the point. it's like so much information compressed in a little space. Thanks for your efforts in making the videos.
I'm taking a course called Python for Data Science Bootcamp. As we cover different topics I've been finding your content covering that topic. I end up taking so many notes from your content and it really helps my understanding. I love your teaching style, thank you.
You have a massive impact on people, you help them understand they can code, thank you for your contribution to helping people achieve goals they never thought they could.
Thank you very much! I was stuck for days on a project and your guide helped me to finally overcome it, this is exactly what i'm looking for in a tutorial and you're amazing at explaining, subscribed!
Thank you! Your videos have been really helpful to me. They have helped me get back into Python and understand it better. Your way of explaining things is simple and easy to follow. I truly appreciate the time and effort you put into creating such valuable content 😄
I just started learning python, and I came across your channel... you make learning python so easy and interesting. thank you
Stonkingly good tutorial. So glad I happened across your channel.
I enjoyed the video. Very clear explanation and perfect pace. Thanks a lot!
This was great. Really love how you went through the examples. Can't wait to see the next video.
filming it tomorrow! (I had a very long weekend full of adventures which I'm still recovering from hahaha)
This is great! Very straight forward and comprehensible for beginners. Thank you! Will definitely start learning from more of your vids
This was a genuinely fantastic tutorial, thank you!
I am really impressed by your teaching! It is fantastic! Super well planned, clear, with the right depth, very well delivered! I have gone over my videos here and yours are among the best. For Python, I am going to choose your videos over all others. Do have: -learn programming using Python - type of videos? If you don´t, I think you should do them. Thank you!
This is good!!.
Would be great if you combine all videos of Numpy in a full single video.
You're an excellent help as always- thanks
Thank you so much I love your work and it helps me a lot before my Python exam!
Yeeyy!! Best of luck with your exam!! :D
you are the best teacher 💪, hope you are doin great in your college classes 🌻☘️
As always bringing great content to us! Thanks for sharing your knowledge with us. You are awesome!
Thank you so much Michael! 😀
I‘m impressed. Amayzing video, amazing explanations! From now on you will be my go to to understand Python. Thank you!
Please do it! I mean to dedicate a video on bit, memory and hardware stuff(Please refer to 8:00 in this video)
Wow, great tutorial, thanks! I like taking notes on these while listening
Very useful !!! Very clear explanation! 🏅🏅🏅Thank you so much !!! 🙏
The beautiful teacher taught me python, so happy
Just found your videos. Thanks for sharing your work.
I would love to watch a video on how different operating systems handle small data sizes!
Beautifully Explained!
Thank you so much for your videos. Could you do a video in the future about how to manage arrays with more than 3 channels?. Hyperspectral images contains a lot of channels. It could be great and innovative include a video about this. Thanks in advance. The best channel I found here!!!!
Thank you Marya for this video. Love it!
Love this channel. Well explained and presented in an engaging way.
I'm working on a program now with four small integer arrays, and I'm wondering whether using numpy arrays is of any real benefit. I'm only doing small scale analysis like avgs. Is there any reason not to?
Beautifully explained... thanks
Your videos are so amazing. I am watching them over and over till u become a pro! You are a so awesome. Thank you. Would really like a video on hardwares please. Looking for latest 2024 laptop options for a data analyst/data engineer
Thank you for the amazing tutorial, this is so helpful!!
Thank you so much, Brandon! Super happy to help! 😀😀😀
Awesome explanation, thanks a lot! Cheers from Brazil!
Hello
I really appreciate your videos, and more importantly, you have a good grasp of the thing. I would be glad if you made the videos about hardware and bits. Thank you in advance
love your videos! easy to understand..More power mam!
Nice examples and explained thoroughly.
best one i could find.
tnk
Well simplified, indeed. Good job, and thanks!
Thank you! 😊
@@PythonSimplified Most welcome
Love your teaching i am computer science student
Amazing, the best tutorial ever ❤❤❤❤❤❤
Great tutorial video! Thanks a lot!
Thanks for sharing. It was informative.
Bring an end to end project from collection of dataset, model building creating simple ui to consume model. Till deployment in the cloud. That would be great experience..
Definitely sounds like something we can do in weekly live streaming sessions! 😀
I'm getting my setup prepped and ready for it (just waiting for my fancy microphone arm to arrive before I can do so)
Thanks for the suggestion! 😊
(BTW if we're talking about AI models, the best datasets are already collected, I have a nice video introduction on the topic: ruclips.net/video/8z2oLfK2sIc/видео.html )
that lipstick colour is next level
Great explanation! Could you please dedicate a video for the bit, memory and hardware stuff(8:00 in this video)?
Lipstrick color is really deep.... You're naturally so beautiful! By the way... i like your teaching style.😍
Hi Maria, i've run out if array capacity, populating it from huge list of strings, and it throws me 'remote server disconnect error' when i try to print it to the console. Is there a way to work with big data in python? Some other lib maybe?
Always amazing !
loved ur way of making things learn...... subscribed
very beautiful explanation
awesome, some great info in this video, thanks for sharing 👍 I would love to see a simple video on bytes, word boundaries, threading, matrices transformations, photosynthesis, quantum computing and vertical platforms please.
I'm actually a big fan of photosynthesis, I live in the forest 🤣🤣🤣
matrix transformations though is gonna be in the upcoming NumPy operations tutorial, so very soon! 😁
@@PythonSimplified 😄 I was just happy it was Friday, got a bit excited, sorry 😃
Check out Kitty Yeung for quantum computing.
@@NiHaoMike64 thanks, I'll search for that.
Great video, beautiful teacher.
Thank you for this tutorial, I am new to NumPy. I need to know all methods and how to use them. I am studying courser Machine learning
Great video. Great channel. Needs more caffeine addiction. 🤗
Youre way better than my uni teacher wtf 😂 he literally brushes over it, plus the lag time of learning to assignments. By the time the assignment is due the lectures will only brush on the topic 🙃
Thank you, deary... I appreciate this work and knowledge you have given of yourself. Seems I have a long road ahead for what I want to accomplish with python, but I was hoping to see something on arrays involving, say, a live camera feed pixel array. My task at hand: Array manipulation and processing, for tracking stars in a telescope/camera view.
Live camera feed involves some kind of visualization library rather than NumPy, checkout my OpenCV + ipWebCam tutorial:
ruclips.net/video/UdCSiZR8xYY/видео.html
You'll be able to use your mobile phone to track the stars.
On top of that, you'll need to involve some Machine Learning techniques so that your computer can interoperate the image. I don't have any object detection tutorials yet, but I have many image classification ones in my AI + ML playlist:
ruclips.net/p/PLqXS1b2lRpYTpUIEu3oxfhhTuBXmMPppA
And you can probably speed up processes by using Yolov5 (pre trained neural network) to do that.
I hope it helps and good luck! 😊
@@PythonSimplified Since that comment I have gotten the program to process live feed and found what sped the process up, and what slowed it down.. Now I am working with vectors to process projections of a sample point vector ("star location center") onto a reference of the two telescope axes... It is actually working... but I Love the help that you others bring.. so thanks a bunch.. I will take a look at the other information you shared. I don't want to tip the boat over at this time. My system will be hared wire, that is, not wireless operated at this time. Perhaps in the future..
This sounds amazing! I love astronomy!
@@adisonfryman144 Wonderful! I do as well... I have spread myself so thin to accomplish this: Designing, machining, circuit board creation to coding in C++ in Arduino for slewing and tracking, to the Python based autoguiding system and serial communication between them... When I start getting good images, I hope to share...
The video was as beautiful as you.
- Your new pythonista
非常好的语言培训,期待完整的教程
И, да, спасибо за видео и прекрасную картинку. Приятно смотреть
she is a genius!
i love your make up and sound as well!❤
Very helpful. Thanks
Thanks a lot!
very great content, thank for sharing
Thank you for this clearly explain video about numpy.
you can check my playlists, there are most of the lecture tutorials for Python and R, step by step, sequentially .
great explaination....
Hello, what does the k stand for? thank you
🙂
I recoded one of my projects from python lists to numpy recently and it brought the execution time down from about 25 minutes to less than a minute. Most of that minute is io operations in reading and writing the data to by database, the rest is probably one operation where I can't apply arithmetic directly to the array and I have to loop through each element individually, and I can't use multiprocessing or multithreading because I need the answer to the previous item as the starting point for the next item - at least for that individual section of data. I can split the data into about 15000 sections and work on individual sections in parallel.
I am dealing with about 10 million rows of data each with 6 columns.
wow! that is quite an impressive sounding project 👍
This is awesome Katrina!! 😃
It demonstrates how selecting a good algorithm and implementing it with the right library is much more effective than upgrading computer hardware!
We rarely think of how our data is being stored in memory when working with Python, but if we do - our software suddenly gets superpowers!!! 😄
I believe your comment will motivate many other folks to try and improve their code, good job!! 💪💪💪
Waiting🥰
Love your teaching style ! and your beautiful! its a win win thank you
Thanks ❤️ this video .
You're absolutely welcome! enjoy! 😀
Очень понятно, спасибо!
Thank you :)
Hello . IM from Oʻzbekiston
The good thing about these matrix computation libraries is that, they follow a very familiar API design pattern, e.g if you are learning numpy then you will feel right at home while using pytorch as it derives a lot of the matrix computation functionality from Numpy.
I Absolutely agree, Aamir! Pytorch rocks!! 😀😀😀
Beauuutiful! :D
i like when you said beautiful. 😄
8:01 Please dedicate an entire video to hardware and bits and all those technical stuff!
I would like to learn from your tutorial as well teach more through practical apply your teaching way
Hi Ali! 😊
We will practice everything we learned in this tutorial in a very cool upcoming NumPy project!
We'll try to replicate simple images by using our Numpy skills: we'll create 3 dimensional data structures,
where the first channel stores intensity of red colours, the second channel intensity of Blue colours and the last one - Green.
We will then convert the numeric data into an image file (using PILLOW or CV2, haven't decided yet)
So we will have a visual example of what numbers mean in terms colours and images 😀
So definitely stay tunned! 😉
@@PythonSimplified I agree with you and time arrangement is important if I miss your tutorial I watch later upload more videos.
Hi, new subscriber here -- please do a vid on the hardware/bits explanation if you haven't already!
Really liking this channel more than some others on Python I've come across, your way of teaching concepts is straightforward, keep it up!
Hi marya i have a question about regex in python
how can i get specific matched groups by using input function ?
Your question does not make sense. Regex just needs a string or bytes to compare something and that's all, idk the role of input in all of this, you have to be more specific.
Could you please include an example of what you meant?
How your input function look like or what are you trying to achieve?
example: "find all the the entries that include uppercase letters" or any other condition we can use to understand your question because I don't think I got it... 😊
Perfect
Super 🤩
Hey Mariya! I was wondering if you are considering to do another video reviewing projects in the future
Maybe on the next code jam? not sure, time will tell 😀
I learnt python but don't where to use for loop while
define classes objects and all other basic and advance things
because I want to create a app but how to change code into a gui
I have a full playlist of GUI tutorials for beginners:
⭐ ruclips.net/p/PLqXS1b2lRpYRVrpyN19e3vzLZfFoPLTRL
I have a For Loops tutorial too:
⭐ ruclips.net/video/dHANJ4l6fwA/видео.html
As well as a bunch of OOP and classes tutorials:
⭐ ruclips.net/video/f0TrMH9s-VE/видео.html
⭐ruclips.net/video/-LsuiVGO-88/видео.html
⭐ ruclips.net/video/6c6NYPjO_rI/видео.html
Everything you asked about can be found on my channel 😊
You are a fantastic teacher! I am glad I found you. I am having an issue and I do not understand why. I am pasting the code and for some reason I am getting a syntax error on the p in print:
from_list= np.array([[1,2,3,4],[5,6,7,8]])
array_2d= np.array((np.arange (0,8,2), np.arange (1,8,2))
print(array_2d)
can you what is wrong? Thank you!!!!!!!!!!
Thank you so much for the lovely feedback! 😃 from what I see here, it's just a tiny typo: remove the space in between np.arrange and (1,8,2) in array_2d and you're good to go! 😉
@@PythonSimplified Beautiful! Thank you! This is really hard sometimes and frustrating and I am usually not frustrated. I have so much to learn, but I am so glad to have you and some of the other great content creators. Honestly, I do tend do understand you more clearly than the others and it does not hurt that you are easy on the eyes. Hopefully that does not offend you. It is just much easier to stay engaged because I have to watch videos over and over again, so anything positive helps me stay the course. I am taking my MS in Data Science and a MBA while working FT. I watch the monotone lectures and watch your far more vivid videos, !they are truly a contrast. Thank you so much! GL and God Speed!
@@eddiesito Thank you so much Eddie! 😁😁😁
Best of luck on your exciting journey, it gets easier with time and practice - I promise! 😊
(and BTW it's very hard to be offended with compliments hahahaha women who have issues with that must be crazy 🤣🤣🤣)
@@PythonSimplified These days you just never know. I wanted to be honest and not detract from you obvious amazing talent, I am glad you responded well. Thank you!
Thanks
Awesome.
Yo simplified nice tutorial I want to ask you something about (array) why array is important in python ? I mean for what kind of work we use array and why don't we use list as compared to array?? 🥴
And what are the benifits to use array ? And what you like about array?("I'm kinda new in that thing!!! ;-) ") xD I need to learn more about array....
Hello. There are several ways to use it. For example for improving the performance for tasks of linear algebra (matrix operations) or artificial intelligence
@@vasylpavuk391 thanks vasyl 🤝🙋♂️
Yo yo Udbhav! 😁
Lists are an abstract data structure in many programming languages (abstract = theoretical). They're simply defined as a collection of items. In order to implement them we usually have 2 options:
1. We can implement them as an array.
(A collection of items OF THE SAME KIND).
2. We can implement them as a linked-list. Where we work with something called "pointers" to store where the item is located in memory (yes, it's just as complex as it sounds hahahaha 😅 that's why I try to avoid it whenever possible)
Now the beauty of Python, is that it actually has the ability to implement lists! it can store different types of data on the exact same list, for example:
my_list = ["apple", True, 1, 0.5, "cat"]
This is not something we can do with c++ as lists cannot be implemented as is.
So before we can store a collection of items in c++, we need to make sure that all the items have the exact same data type.
Now, even though we have the ability to implement lists in Python - by doing so we waste a lot of memory resources. So our code runs - but it uses more memory than we potentially can use.
By using arrays in Python, we solve this problem as we restrict the number of memory bits each array item can use.
So if we are dealing with an array of boolean values, we can select the np.bool8 data type which only takes up 1 byte (8 bits).
While by default, if we are not being specific with the data type - each of the array items would take up 64 or 32 bits - which is a HUGE waste of resources! 😃
Check out this video at 04:27 where I explain it a bit differently 😉
I hope it helps!
@@PythonSimplified wow, длинное описание, надеюсь человек сможет понять и оценить :)
@@PythonSimplified thanks mariya you explain it well !! 🤜🤛👏
Drives me NUTS! Gotta have the library, but most of it is voodoo mysticism to me.
Do you really need to learn numpy arrays if you know pandas well? Not sure I unde how they intersect. Thanks
NumPy deals with numeric data structures and mathematical operations, Pandas deals with organizing all kinds of data into tables, manipulating it and visualizing it. They can definitely intersect if you're working on a database full of numeric data, or if your plotting your arrays in a graph but otherwise - they have very different purposes so you can't really replace one with another 😀
Checkout my Pandas basics tutorial to see the difference:
ruclips.net/video/zN2Hua6oII0/видео.html
I hope it helps! 😁
good jobb
Which editor is best for python and how if I want to become python developer than what I have to do plz reply....
If you want to be a software developer you most likely will never be just a 'python developer'. Learn how to write clean code and learn how to solve problems in code. Start with small projects and work your way up to more complex ones. Read other peoples code and learn from it. Most importantly: Have fun doing it, otherwise, whats the point? 🙂
@@richi1235 maybe be you right but I think which developer I make or app or web I confused which I choose for my better career or I choose game development I bit confused 😕 😅.....
@@sea-sumatra6925 well try things out and go for the thing that is the most enjoyable to you. if you learn the craft the right way you will probably be fine with either choice in terms of job opportunities.
I absolutely agree with @@richi1235 ! 😊
You can start with the basic programming concepts such as: variables, data types, control flow operations (for loops, while loops, conditional statements, functions) then move on with object oriented programming (classes) and then with external libraries (NumPy, Pandas, etc.)
I have a really nice vlog where I explain my road map of learning Python, you can check it out here 😁:
ruclips.net/video/wFEC7VbWBZo/видео.html
Additionally, I recently had an interview on Eric Willsons' podcast, where we discuss this roadmap in more detail. Here's the community post where I shared it: ruclips.net/user/postUgkxoKgTyBWEMjKrz6HIncB5uxmrQiWEGXu4
And the best part is, while you use Python to learn these programming concepts - you can actually apply them on almost any other programming language!!!
I find that starting with Python is very easy and extra intuitive, but once you are comfortable with everything you've learned - switching to Javascript, C#, C++, etc will be incredibly simple! 😀😀😀
Best of luck on your programming journey! 💪💪💪
@@PythonSimplified I choose python only but I want to go in game development what I have to do
Thanks sister for your reply 😘 ❤.....
Thx
tbf numpy feels like a circumvention of pythons horrible dynamic versatility for the specific case of numerics, like a hollow connection to the power of more static languages such as C/C#/C++. Because there are more and more libraries trying to make Python more efficient by combining elements from other languages it becomes slightly messier and incomprehensible from a close to the operating system perspective. nywys nice insight/tutorial
NumPy is written in C, however I still find it to be very Pythonic and intuitive... I actually think it's a huge benefit rather than a disadvantage! 😀
🔥❤️
beauty with brain😲🙄
Boolean - 0..255
Maria, you're cut out to be teacher...thank you!
Можно ли транспонировать 2х мерный архив?
I believe you can do it with my_array.reshape((*a flipped shape to the original archive*)) but I don't know if I fully understood the question 😊
I must admit that my Russian knowledge doesn't include complex words, I left Crimea when I was 6 years old so my vocabulary can't really handle words like "транспонировать" hahaha 😅😅😅
@@PythonSimplified it not nessesary to use russian language. I can write and read in eng
@@PythonSimplified транспонировать - is simple. It is transpose