numpy arrays to python compatible arrays

Discussion in 'Python' started by Javier Montoya, Jun 10, 2010.

  1. Dear all,

    I'm new to python and have been working with the numpy package. I have
    some numpy float arrays (obtained from np.fromfile and np.cov
    functions) and would like to convert them to simple python arrays.
    I was wondering which is the best way to do that? Is there any
    function to do that?

    Best wishes
     
    Javier Montoya, Jun 10, 2010
    #1
    1. Advertising

  2. On Jun 10, 2010, at 9:58 AM, Javier Montoya wrote:

    > Dear all,
    >
    > I'm new to python and have been working with the numpy package. I have
    > some numpy float arrays (obtained from np.fromfile and np.cov
    > functions) and would like to convert them to simple python arrays.
    > I was wondering which is the best way to do that? Is there any
    > function to do that?


    Hi Javier,
    Since you are new to Python I'll ask whether you want to convert Numpy
    arrays to Python arrays (as you stated) or Python lists. Python lists
    are used very frequently; Python arrays see very little use outside of
    numpy.

    If you can use a Python list, the .tolist() member of the numpy array
    object should do the trick.

    bye
    P
     
    Philip Semanchuk, Jun 10, 2010
    #2
    1. Advertising

  3. Javier Montoya

    Martin Guest

    On Jun 10, 9:02 pm, Philip Semanchuk <> wrote:
    > On Jun 10, 2010, at 9:58 AM, Javier Montoya wrote:
    >
    > > Dear all,

    >
    > > I'm new to python and have been working with the numpy package. I have
    > > some numpy float arrays (obtained from np.fromfile and np.cov
    > > functions) and would like to convert them to simple python arrays.
    > > I was wondering which is the best way to do that? Is there any
    > > function to do that?

    >
    > Hi Javier,
    > Since you are new to Python I'll ask whether you want to convert Numpy  
    > arrays to Python arrays (as you stated) or Python lists. Python lists  
    > are used very frequently; Python arrays see very little use outside of  
    > numpy.
    >
    > If you can use a Python list, the .tolist() member of the numpy array  
    > object should do the trick.
    >
    > bye
    > P


    as Philip said...though I very much doubt you really want to do this?
    Why wouldn't you just keep it in a numpy array?
     
    Martin, Jun 10, 2010
    #3
  4. On Jun 11, 12:29 am, Martin <> wrote:
    > On Jun 10, 9:02 pm, Philip Semanchuk <> wrote:
    >
    >
    >
    > > On Jun 10, 2010, at 9:58 AM,JavierMontoyawrote:

    >
    > > > Dear all,

    >
    > > > I'm new to python and have been working with the numpy package. I have
    > > > some numpy float arrays (obtained from np.fromfile and np.cov
    > > > functions) and would like to convert them to simple python arrays.
    > > > I was wondering which is the best way to do that? Is there any
    > > > function to do that?

    >
    > > HiJavier,
    > > Since you are new to Python I'll ask whether you want to convert Numpy  
    > > arrays to Python arrays (as you stated) or Python lists. Python lists  
    > > are used very frequently; Python arrays see very little use outside of  
    > > numpy.

    >
    > > If you can use a Python list, the .tolist() member of the numpy array  
    > > object should do the trick.

    >
    > > bye
    > > P

    >
    > as Philip said...though I very much doubt you really want to do this?
    > Why wouldn't you just keep it in a numpy array?


    Thanks for the suggestions! The main reason not to use a numpy array
    is because I'm
    using a package that doesn't work with numpy arrays.
    With the .tolist() conversion it's now working fine, thanks!
     
    Javier Montoya, Jun 12, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. drife
    Replies:
    1
    Views:
    367
    Travis E. Oliphant
    Mar 1, 2006
  2. Rob Clewley
    Replies:
    6
    Views:
    441
  3. Duncan Smith
    Replies:
    3
    Views:
    423
    Duncan Smith
    Apr 25, 2007
  4. Replies:
    2
    Views:
    492
    Robert Kern
    Nov 13, 2007
  5. pantagruel
    Replies:
    0
    Views:
    246
    pantagruel
    Feb 17, 2006
Loading...

Share This Page