About 8,130,000 results
Open links in new tab
  1. Replace specific values in a matrix using Python

    Oct 6, 2014 · I have a m x n matrix where each row is a sample and each column is a class. Each row contains the soft-max probabilities of each class. I want to replace the maximum value in …

  2. How to replace some elements of a matrix using numpy in python

    Oct 31, 2019 · Replace some elements of a 1D matrix. Let's try to replace the elements of a matrix called M strictly lower than 5 by the value -1: >>> import numpy as np >>> M = …

  3. How to Replace Elements in NumPy Array (3 Examples) - Statology

    Jul 11, 2022 · You can use the following methods to replace elements in a NumPy array: Method 1: Replace Elements Equal to Some Value. my_array[my_array == 8] = 20. Method 2: Replace …

  4. Replace Values in NumPy Array by Index in Python - Python

    May 12, 2025 · This article explains how to replace values in NumPy array by index in Python using four different ways such as simple indexing, multiple values at a time, boolean indexing, …

  5. replace matrix element python 3.4.3 - Stack Overflow

    Oct 31, 2015 · I need to replace an element of a matrix. I initiate a 4x4 matrix through the command M=4*[4*[0]]. For example I want to change the (0,1) element. For logic I write: …

  6. How can I change just one element of a matrix in python?

    As you already noticed, since matrix[0], matrix[1] and matrix[2] are identical – are one and the same object – the modification affects all rows, not just the one row you meant to modify. …

  7. python - Replace all elements of a matrix by their inverses

    Jul 11, 2016 · Here is a matrix: A = np.array([[1,0,3],[0,7,9],[0,0,8]]). I want to find a quick way to replace all elements of this matrix by their inverses, excluding of course the zero elements. I …

  8. how to edit the values in a matrix in python? - Stack Overflow

    Feb 4, 2020 · I think the solution you are looking for though is a deep copy rather than a shallow copy. You can use Python's built-in list.copy() method to achieve this. for x in range(0, 3): …

  9. How to Replace Values in a List in Python? - GeeksforGeeks

    Jan 4, 2025 · In this article, we are going to see how to replace the value in a List using Python. We can replace values in the list in several ways. The simplest way to replace values in a list …

  10. NumPy: Replacing all array elements that satisfy condition

    Jan 23, 2024 · One common operation in NumPy is to replace elements in an array that meet a certain condition. This technique is powerful for data manipulation and preprocessing. In this …

Refresh