Learn to discover attributes of NumPy arrays in this video tutorial by Charles Kelly. These are explained in the context of computer science and data science to technologists and students in preparation for machine learning, applied statistics, neural net
- [Instructor] The file Attributes of NumPy arrays in your exercise folder contains an import statement for NumPy, and an array named a, which is pre-populated with 24 elements and is reshaped to two by three by four. Go to the Cell menu and click Run All. This uses the import statement and initializes the array a.
If I wanna find the number dimensions in a, I can type the attribute a.ndim. We find out that it has three dimensions. If I wanna find out the shape of a, I use the shape attribute. If I wanna find the size of a, I can use the size attribute. Here it's telling us that a has 24 elements. It corresponds to these 24 elements. If I wanna find out the data type for elements within a, I can use the dtype attribute, and we find out that each of these is a 32 bit integer.
If I wanna find the size, and this is going through the same as integer 32, I can use the item size attribute. It tells us that a 32 bit integer contains four bytes. Finally, I can use the type function on a, and find out that its type is a numpy.ndarray. This has just been a quick summary of the attributes of arrays and how you can find them using the dot notation.
- Using Jupyter Notebook
- Creating NumPy arrays from Python structures
- Slicing arrays
- Using Boolean masking and broadcasting techniques
- Plotting in Jupyter notebooks
- Joining and splitting arrays
- Rearranging array elements
- Creating universal functions
- Finding patterns
- Building magic squares and magic cubes with NumPy and Python
Skill Level Intermediate
2. Create NumPy Arrays
3. Index, Slice, and Iterate
4. Plots: Matplotlib and Pyplot
5. Manipulate Arrays
6. Short Examples
7. Extended Examples
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.