About 3,830,000 results
Open links in new tab
  1. Most efficient way to map function over numpy array

    Feb 5, 2016 · What is the most efficient way to map a function over a numpy array? I am currently doing: import numpy as np x = np.array ( [1, 2, 3, 4, 5]) # Obtain array of square ...

  2. How do I create an empty array and then append to it in NumPy?

    NumPy arrays are stored in contiguous blocks of memory. To append rows or columns to an existing array, the entire array needs to be copied to a new block of memory, creating gaps for the new …

  3. How do I read CSV data into a record array in NumPy?

    Aug 19, 2010 · data_array = np.asarray(data, dtype = <whatever options>) on 4.6 million rows with about 70 columns and found that the NumPy path took 2 min 16 secs and the csv-list comprehension …

  4. What is the difference between ndarray and array in NumPy?

    Jul 30, 2022 · 364 numpy.array is just a convenience function to create an ndarray; it is not a class itself. You can also create an array using numpy.ndarray, but it is not the recommended way. From the …

  5. python - Is there a NumPy function to return the first index of ...

    Jan 11, 2009 · I know there is a method for a Python list to return the first index of something: >>> xs = [1, 2, 3] >>> xs.index (2) 1 Is there something like that for NumPy arrays?

  6. How do I remove NaN values from a NumPy array? - Stack Overflow

    Jul 30, 2022 · x = x[~numpy.isnan(x)] Explanation The inner function numpy.isnan returns a boolean/logical array which has the value True everywhere that x is not-a-number. Since we want …

  7. How to remove specific elements in a numpy array - Stack Overflow

    Jun 12, 2012 · Note that numpy.delete() returns a new array since array scalars are immutable, similar to strings in Python, so each time a change is made to it, a new object is created.

  8. Frequency counts for unique values in a NumPy array

    How do I efficiently obtain the frequency count for each unique value in a NumPy array?

  9. Open / load image as numpy ndarray directly - Stack Overflow

    The result of imageio.imread is already a NumPy array; imageio.core.util.Image is an ndarray subclass that exists primarily so the array can have a meta attribute holding image metadata.

  10. python - NumPy array is not JSON serializable - Stack Overflow

    In the default function check if the object is from the module numpy, if so either use ndarray.tolist for a ndarray or use .item for any other numpy specific type.