On 09/15/2011 11:55 AM, neeru K wrote:
Dear Gary,
thank you for the reply.
I will be more specific and take the same example that you have given and tell you what is my problem -
array([0.0, 1.3, 2.45, 3.87, 4.54, 5.11, 6.90, 7.78, 8.23, 9.01])
from this array I want to a sub-list with lower and upper indexes that are not present in the above array for example - sub-list[3, 8]
Is there a function for this?
thank you
niranjan

You say "index", but I think that is not what you mean. An index is in integer referring to an element's position in the array. The "value" at an index is what I believe you are referring to.

Nevertheless, I think list comprehension is what you want:
    [ x  for x in A  if 3.0 <= x <= 8.0 ]
will extract all the values between 3 and 8 from the array A and create a new list containing them.

If you want the new list to be a numpy array then
    numpy.array([ x  for x in A  if 3.0 <= x <= 8.0 ])





On Thu, Sep 15, 2011 at 10:54 PM, Gary Herron <gher...@digipen.edu <mailto:gher...@digipen.edu>> wrote:

    On 09/15/2011 09:40 AM, neeru K wrote:

        Dear Python Users,
        I am trying to write a code for visualization (raster plots
        and peri-event time histogram) of time series
        electrophysiological data using numpy, scipy and matlplotlib
        in python. I am importing the data into list using loadtext
        command.
        I was curious if anyone is aware of a function in numpy that
        can *extract a smaller list containing numbers from a larger
        list* given the upper and lower limit of the values between
        which the smaller list lies.
        Thank you in advance.
        Sincerely,
        niranjan

-- Niranjan Kambi
        Senior Research Fellow,
        Neeraj Lab,
        National Brain Research Centre,
        Manesar, Gurgaon-122050
        Haryana, INDIA
        Ph:+919818654846 <tel:%2B919818654846>
        website:-
        http://www.nbrc.ac.in/faculty/neeraj/Lab_webpage/Niranjan_Kambi.html
        email:- neuro.n...@nbrc.res.in <mailto:neuro.n...@nbrc.res.in>
        <mailto:neuro.n...@nbrc.res.in
        <mailto:neuro.n...@nbrc.res.in>>, neuron...@gmail.com
        <mailto:neuron...@gmail.com> <mailto:neuron...@gmail.com
        <mailto:neuron...@gmail.com>>

    Do mean to extract a sub-list from a list based on lower and upper
    indexes into the list?  Python has a standard notation for
    indicating sub-lists, and numpy implements them:

    >>> a = numpy.array(range(10))
    >>> a
    array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
    >>> a[3:6]
    array([3, 4, 5])

    If you mean something else, please be more specific, and we'll try
    again.

    Gary Herron


-- Gary Herron, PhD.
    Department of Computer Science
    DigiPen Institute of Technology
    (425) 895-4418 <tel:%28425%29%20895-4418>

-- http://mail.python.org/mailman/listinfo/python-list








--
Gary Herron, PhD.
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to