convert « numpy « Python Data Type Q&A

Home
Python Data Type Q&A
1.array
2.date
3.dictionary
4.Format
5.integer
6.List
7.numpy
8.regex
9.string
10.tuple
Python Data Type Q&A » numpy » convert 

1. Python File Slurp w/ endian conversion    stackoverflow.com

It was recently asked how to do a file slurp in python: link text And it was recommended to use something like

with open('x.txt') as x: f = x.read()
How would I go about ...

2. numpy : How to convert an array type quickly    stackoverflow.com

I find the astype() method of numpy arrays not very efficient. I have an array containing 3 million of Uint8 point. Multiplying it by a 3x3 matrix takes 2 second, but converting ...

3. Converting NumPy array into Python array_like structure?    stackoverflow.com

How do I convert a NumPy array to a Python array_like structure (for example [[1,2,3],[4,5,6]] ), and do it reasonably fast?

4. Converting arrays between NumPy and JPype?    stackoverflow.com

Does a library or script exist to convert between NumPy and JPype arrays?

5. numpy arrays type conversion in C    stackoverflow.com

I would like to convert the numpy double array to numpy float array in C(Swig). I am trying to use

PyObject *object = PyArray_FROM_OT(input,NPY_FLOAT)
or
PyObject *object = PyArray_FROMANY(input,NPY_FLOAT,0,0,NPY_DEFAULT)
or
PyObject *object = PyArray_FromObject(input,NPY_FLOAT,0,0)
or
PyObject *object = ...

6. Converting a 2D numpy array to a structured array    stackoverflow.com

I'm trying to convert a two-dimensional array into a structured array with named fields. I want each row in the 2D array to be a new record in the structured array. ...

7. Convert a list of 2D numpy arrays to one 3D numpy array?    stackoverflow.com

I have a list of several hundred 10x10 arrays that I want to stack together into a single Nx10x10 array. At first I tried a simple newarray = np.array(mylist) But that returned ...

8. In-place type conversion of a NumPy array    stackoverflow.com

Given a NumPy array of int32, how do I convert it to float32 in place? So basically, I would like to do

a = a.astype(numpy.float32)
without copying the array. It is ...

9. numpy array conversion to pairs    stackoverflow.com

I'm not sure how it is called in python i think its a pair Anyway I have a huge numpy array, its format is like

FFnetlayer0 =   [ 0,  243, ...

10. Python: how to convert a complex array to a 2D array?    stackoverflow.com

As a C++ programmer, I'm used to access vectors in C++ style:

for (i=0; i<max_x; i++) {
  for (j=0; j<max_y; j++) {
    vec[i][j] = real(complex_number(j+i*max_x))
  }
}
Now I ...

11. Convert vtkPoints to numpy array?    stackoverflow.com

I am using Mayavi2 in a Python script to calculate 3d iso-surfaces. As a result I get a vtkPoints object. Now I want to convert this vtkPoints object ('vtkout' in the ...

12. efficient python array to numpy array conversion    stackoverflow.com

I get a big array (image with 12 Mpix) in the array format from the python standard lib. Since I want to perform operations on those array, I wish to convert it ...

13. Converting a list of points to a numpy 2D array    stackoverflow.com

I'm using genfromtxt to import essentially a 2D array that has all its values listed in a text file of the form (x's and y's are integers):

    x1 ...

14. How can I efficiently transform a numpy.int8 array in-place to a value-shifted numpy.uint8 array?    stackoverflow.com

I have a large numpy array of signed bytes (dtype int8). It contains values in the full range -128 to +127. I'd like to convert the efficiently to an array ...

15. how to convert 2d list to 2d numpy array?    stackoverflow.com

I have a 2D list something like

    a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] 
and I want to convert it to a 2d ...

16. Convert numpy array into characters?    python-forum.org

>>> init = ["foobar", "foobaz", "foobat"] >>> init = [map(ord, s) for s in init] >>> init [[102, 111, 111, 98, 97, 114], [102, 111, 111, 98, 97, 122], [102, 111, 111, 98, 97, 116]] >>> b = numpy.array(init, "B", order=2) >>> b array([[102, 111, 111, 98, 97, 114], [102, 111, 111, ...

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.