Loading tutorials
shape, ndim and dtype mean on an ndarray. Here you learn the main ways to build arrays and what each one does to shape and dtype. Many shape and dtype surprises later 5 min readshape, ndim and dtype, which the previous chapters covered. Here you will learn how to select data from an array with i5 min reada[1:3] and a[:, 1], and that you know what shape means. It covers when NumPy shares memory between arrays, when it allocates new memory, and the bugs that follow when you guess wrong.4 min reada[1:3, :2]), the difference between a view and a copy, and how comparison operators work elementwise on arrays. It covers the two ways to select data that basic slicing cannot express: selecting by a condition, and selecting by a list of positions. Both5 min readshape, ndim and dtype, and index and slice arrays. It also assumes you know basic Python functions and operators. Here you will learn how NumPy applies operations to whole arrays at once, what a universal function is, and which errors and surpri4 min readshape and ndim, and apply elementwise operations such as a + 1 or np.sqrt(a). It also assumes basic Python and the idea of a matrix as rows and columns. Everything here builds on the previous chapter's idea that an array operation 5 min readshape and ndim, and index and slice them. You should also know that a basic slice returns a view. Here you will change an array's shape without changing its data, and combine several arrays into one. Both skills are needed before broadcasting, bec5 min readshape and ndim mean, and that you have used elementwise operators such a5 min readsum and mean take an axis argument. It also assumes you know the broadcasting rule: NumPy compares shapes starting from the trailing (rightmost) dimension, and two dimensions are compatible if they are equal or o6 min readnp.where is NumPy's vectorized if/else. It picks values from one of two sources for every element, based on a condition, and it does so without a Python loop. This chapter covers its two call forms, how broadcasting applies to it, how the result dtype is chosen, and the mistakes that cause warning6 min readnp.newaxis, reshape and keepdims. Here you learn 6 min read