Indexing15:54 with Craig Dennis
The ndarry data structure is quite Pythonic, so indexing works as expected. NumPy introduces some handy shortcuts and powerful indexing options. Fancy.
A different solution
There are actually a couple of ways to add a new axis to your array other than wrapping it with brackets like this
Another popular solution is to use the
np.newaxis property. So the code would look something like this:
# Slice all the rows and add a new axis fake_log[:, np.newaxis]
My Notes for Multidimensional Arrays
## Multidimensional Arrays * The data structure is actually called `ndarray`, representing any **n**umber of **d**imensions * Arrays can have multiple dimensions, you declare them on creation * Dimensions help define what each element in the array represents. A two dimensional array is just an array of arrays * **Rank** defines how many dimensions an array contains * **Shape** defines the length of each of the array's dimensions * Each dimension is also referred to as an **axis**, and they are zero-indexed. Multiples are called **axes**. * A 2d array is AKA **matrix**.
You need to sign up for Treehouse in order to download course files.Sign up