help regarding extracting a smaller list from larger one

Gary Herron gherron at digipen.edu
Thu Sep 15 19:24:15 CEST 2011


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
> website:- 
> http://www.nbrc.ac.in/faculty/neeraj/Lab_webpage/Niranjan_Kambi.html
> email:- neuro.niru at nbrc.res.in <mailto:neuro.niru at nbrc.res.in>, 
> neuroniru at gmail.com <mailto:neuroniru at 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




More information about the Python-list mailing list