Py学习  »  Python

在python中,如何在数据帧索引列表上循环300个数据点?

astralled • 5 年前 • 1435 次点击  

init_list = [] # initial values for chunks 
median_list = [] # list of median values for 300 s intervals 
holding_list = [] # hold values up till what you tell it to
pos_count = 0 # 0 = position 1 for python
for i in range(len(flux_maxij)): 
    holding_list.append(flux_maxij[i]) # append means add on to 
    if pos_count == 0: # '==' means IF it is this value
        init_list.append(i) 
    if pos_count == 299: # 299 = 300 which is the 'end' of the range 
        holding_list.sort() #make it pretty 
        median_list.append(holding_list[149]) # half of 300 is 150,                149 for python
        holding_list = [] 
        pos_count = -1 # -1+1 = o, position 1 when it loops back 

    pos_count += 1

x = np.array([init_list]) # makes arrays for x and y to graph it 
y = np.array([median_list])

plt.plot(x,y, 's')      
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/53036
 
1435 次点击  
文章 [ 2 ]  |  最新文章 5 年前