Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
The ndarray data structure is quite Pythonic, so indexing works as expected. NumPy introduces some handy shortcuts and powerful indexing options. Fancy.
Learn more
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 [fake_log]
.
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**.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up