About 609,000 results
Open links in new tab
  1. python - Dump a NumPy array into a csv file - Stack Overflow

    May 21, 2011 · import numpy as np a = np.asarray([ [1,2,3], [4,5,6], [7,8,9] ]) a.tofile('foo.csv',sep=',',format='%10.5f') The man page has some useful notes: This is a …

  2. python - array.array versus numpy.array - Stack Overflow

    Sep 21, 2008 · If you are creating a 1d array in Python, is there any benefit to using the NumPy package?

  3. python - How do I convert a numpy array to (and display) an …

    7 Using pygame, you can open a window, get the surface as an array of pixels, and manipulate as you want from there. You'll need to copy your numpy array into the surface array, however, …

  4. python - Find nearest value in numpy array - Stack Overflow

    Apr 2, 2010 · How do I find the nearest value in a numpy array? Example: np.find_nearest(array, value)

  5. python - How do I remove NaN values from a NumPy array?

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

  6. How do I count the occurrence of a certain item in an ndarray?

    Dec 24, 2016 · When one wants to count all values in an array, np.unique() is more performant than a solution implemented manually with Numba for sufficiently large arrays. EDIT: It seems …

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

    Jun 12, 2012 · Using np.delete is the fastest way to do it, if we know the indices of the elements that we want to remove. However, for completeness, let me add another way of "removing" …

  8. 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?

  9. python - NumPy array initialization (fill with identical values ...

    May 5, 2011 · I need to create a NumPy array of length n, each element of which is v. Is there anything better than: a = empty(n) for i in range(n): a[i] = v I know zeros and ones would work …

  10. python - Convert Pandas dataframe to NumPy array - Stack …

    Nov 2, 2012 · Use df.to_numpy() It's better than df.values, here's why. * It's time to deprecate your usage of values and as_matrix(). pandas v0.24.0 introduced two new methods for obtaining …