Learn how to change the shape 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 ne
- Before you begin using this notebook,…let's take a look at the documentation for reshape.…In particular, the returns item.…This states "This will be a new view object if possible,…otherwise it will be a copy.…Note there is no guarantee of the memory layout."…It's interesting that,…whereas most of NumPy's function…guarantee a deterministic result,…this particular function, reshape,…does not guarantee a deterministic result.…
Quickly, let's take a look at the shape…for my start array.…And we see it's a one-dimensional array…that contains 24 elements.…The documentation for the reshape function…tells us that it has a name parameter named new shape.…This parameter is an integer,…or a tuple of integers,…that should be compatible with the original shape…of the data that is being reshaped.…If this parameter is an integer,…then the result will be a one-dimensional array.…
The interesting thing in this documentation…is that is says one shape can can be a minus one.…In this case,…the value is inferred from the length of the array…
- 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.