简体   繁体   中英

Calling certain length of elements in a list in Python

Python

I have a list with 5 elements. Each element has 2042 rows and 2 columns (2042,2) .The variable type is numpy.ndarray. I want to call on the first element ( data[0] ) and the first 1440 rows in the second column. So the format right now is data[0][0,1] , which gives me the value in the first row and second column for the first element. How do I write a line to give me the first 1440 rows?

Something like data[0][0:1439,1] , which I know doesn't work--but to that effect.

If it's a numpy array, then

data[0][:1440,1]

Should do the job.

Well, its difficult to assume what has been your approach.

But taking that:

data = [[[i for i in range(2042)] for i in range(2)] for i in range(5)]

The best aproximation to obtain the first 1440 rows in second column, of first element is:

data[0][1][:1440]

Regards!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM