Reshaping & Indexing NumPy Arrays - Learn NumPy Series

preview_player
Показать описание
This Video is a part of a NumPy Tutorial Series: Start the entire series here:

We're continuing on in our NumPy series by talking about how to reshape and index numpy arrays.
We'll talk about reshaping using the reshape method and .T transposes
We'll also talk about how to select a row, column, and specific value from a numpy array using indexing.

Thanks for all the support! Almost to 5k subscribers. Insanely awesome. Thank you for all the kind words!

Join The Socials -- Picking Shoutouts Across YouTube, Insta, FB, and Twitter!
*****************************************************************
Full code from the video:
import numpy as np

#Create simple array

# New Attribute Array Size
# Number of Rows times Number of Columns

# Reshape Array
print(array_b)

#transpose array_a
array_c = array_a.T
print(array_c)

# Access Row
print(array_c[0])

# Access Columns
print(array_c[:,0])

# Access Specific Values
print(array_c[1,1])

Packages (& Versions) used in this video:
Python 3.7
NumPy 1.17

*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:

Check out my website:

If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!

Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!
Рекомендации по теме
Комментарии
Автор

reshape and transpose dont give same output

lonetusker
Автор

how does reshape now how to arrange the contents of the array?

starstenaal
Автор

Thanks Derrick! Which text editor you use.

steveyagci
Автор

reshape is not the same as transpose because transpose simply switches the rows and columns as it is i.e. in this case [[1, 2, 3], [4, 5, 6]] has 2 rows and 3 columns; it will simply be changed to [[1, 4], [2, 5], [3, 6]]. Reshape has several other parameters as well. However ignoring other params and simply taking this example, it's working can be explained as first it writes the whole nd-array to a 1D array and then it picks the elements as per the order given as the argument. Pertinent to the example in the video; [[1, 2, 3], [4, 5, 6]] first goes to [1, 2, 3, 4, 5, 6] and then because the shape specified is 3, 2 hence [[1, 2], [3, 4], [5, 6]].

rufaidakashif
Автор

reshape is not the same as transpose. You even got different results in your video. You explained what is the transpose but not how reshape works

alejandromartinezleon
Автор

You are both handsome and knowledgeable.

hangchen
Автор

This dude looks like he's dangerous! Hee Hee~!

XX-vujo