Yahoo Αναζήτηση Διαδυκτίου

Αποτελέσματα Αναζήτησης

  1. 14 Μαρ 2017 · By definition, the axis number of the dimension is the index of that dimension within the array's shape. It is also the position used to access that dimension during indexing. For example, if a 2D array a has shape (5,6), then you can access a[0,0] up to a[4,5].

  2. 2 Ιουλ 2017 · First we prepare the new index array: >>> idx = numpy.array(list( ... numpy.ndindex(*inp.shape[:2], 1) # Python 3 syntax ... )) Then we update the column which corresponds to the third axis: >>> idx[:, 2] = indices[idx[:, 0], idx[:, 1]] Now we can select the elements and simply reshape the result: >>> inp[tuple(idx.T)].reshape(*inp.shape[:2])

  3. Use the axis keyword to get the indices of maximum and minimum values along a specific axis: >>> np . argmax ( a , axis = 0 ) array([[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) >>> np . argmax ( a , axis = 1 ) array([[2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) >>> np . argmax ( a , axis = 2 ) array([[4, 4, 4], [4, 4, 4]]) >>> np . argmin ( a ...

  4. To get the indices of unique values in a NumPy array (an array of first index positions of unique values in the array), just pass the return_index argument in np.unique() as well as your array. >>> unique_values , indices_list = np . unique ( a , return_index = True ) >>> print ( indices_list ) [ 0 2 3 4 5 6 7 12 13 14]

  5. In the last chapter, I showed you how to index and slice lists to get access to specific elements. When you work with nested lists like matrix from the first example in this chapter, you can use chained indexing: matrix[0][0] will get you the first element of the first row. With NumPy arrays, however, you provide the index and slice arguments ...

  6. 10 Δεκ 2018 · np_array_2d = np.arange(0, 6).reshape([2,3]) And let’s quickly print it out, so you can see the contents. print(np_array_2d) [[0 1 2] [3 4 5]] The array, np_array_2d, is a 2-dimensional array that contains the values from 0 to 5 in a 2-by-3 format. Next, let’s use the NumPy sum function with axis = 0.

  7. ndarrays can be indexed using the standard Python x[obj] syntax, where x is the array and obj the selection. There are different kinds of indexing available depending on obj: basic indexing, advanced indexing and field access. Most of the following examples show the use of indexing when referencing data in an array.

  1. Γίνεται επίσης αναζήτηση για