About 174,000 results
Open links in new tab
  1. how to modify a 2D numpy array at specific locations without a …

    try ndarray.flatten(array), that way you are dealing with a one dim array which can be manipulated with numpy.put(array,[indices],[values]). Then use ndarray.reshape() to get to the original …

  2. Numpy Array Indexing - GeeksforGeeks

    Jan 24, 2025 · Array Indexing in NumPy is used to access or modify specific elements of an array. It allows to retrieve data from arrays by specifying the positions (indices) of elements. This is …

  3. python - 2D array indexing - Stack Overflow

    May 6, 2013 · TL;DR: Use advanced indexing: b[*a.T] = 10. You can also transpose the index array a, convert the result into a tuple and index the array b and assign a value. Converting the …

  4. python - Modify the elements of a Numpy 2D- array at specific …

    Aug 20, 2019 · I have a Numpy 2D-array a and a list of indices list_indices. I want to modify the elements of the array a at each index specified in the list_indices. The current approach I am …

  5. Indexing on ndarrays — NumPy v2.2 Manual

    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, …

  6. Numpy Array IndexingNumpy Array

    Indexing in numpy arrays is a critical feature that allows you to access, modify, and manipulate specific elements, rows, columns, or a subarray within a larger array. This article will explore …

  7. Replace elements in 2D NumPy array using Boolean Indexing

    Mar 26, 2025 · Learn how to create a 2D NumPy array and use boolean indexing to replace elements that meet a certain condition with a specified value. Follow our step-by-step guide.

  8. Numpy Array Indexing: Unleashing the Power of Data Selection

    Common Practices of Numpy Array Indexing. Selecting Elements Based on Conditions; Modifying Subsets of Arrays; Indexing Multi-Dimensional Arrays; Best Practices of Numpy Array …

  9. NumPy Array Indexing Unleashed: Select, Modify, and Master …

    You can use integer array indexing to construct arrays by indexing with other arrays. Example in numpy code row_indices = np.array([ 1 , 0 , 2 ]) column_indices = np.array([ 2 , 1 , 0 ]) # …

  10. Replacing part of a 2D numpy array using indexing

    Aug 7, 2014 · You could use np.ix_ to construct the desired index arrays: In [91]: S[np.ix_([i,j],[i,j])] Out[91]: array([[1, 0], [0, 3]]) In [92]: tmp_arr = np.eye(2)*555 In [93]: tmp_arr Out[93]: array([[ …

  11. Some results have been removed
Refresh