'.describe() function in python with missing counts

I created a nested loop that runs through several items in a multidimensional array. Once the loop has ran through the datasets, I organize the results using the Group.By function and I get some statistics using .describe(). The issue I have is that once I run the statistics, the count is shown as 26 items per group and I know already that there are groups with more or less than 26 items. Could this be an issue with the nested loop?

for i in range (0,253): 
    mos0=swarm_data_array[i]
    mos0_id= mos0[0][0]                                                                             
    mos0_time=mos0[:,1]                                                                                      
    mos0_x_pos=mos0[:,2]
    mos0_y_pos=mos0[:,3]
    mos0_z_pos=mos0[:,4]
    mos0_speed=mos0[:,6]    
    
    for j in range(len(mos0_id)):  
        mos0_ids.append(mos0_id)
        
        for k in range(len(mos0_time)):
            first_mov_time=mos0_time[k]
            last_mov_time=mos0_time[k-1]
            first_movement = dt.datetime.strptime(first_mov_time, '%Y-%m-%d %H:%M:%S.%f')
            last_movement = dt.datetime.strptime(last_mov_time, '%Y-%m-%d %H:%M:%S.%f')
            x = first_movement - last_movement
            total_seconds = x.total_seconds()  
            mos0_dt.append(total_seconds)
                
        for l in range(len(mos0_x_pos)):
            first_mov_pos=mos0_x_pos[l]
            last_mov_pos=mos0_x_pos[l-1]
            x = first_mov_pos - last_mov_pos
            mos0_x_dpos.append(x)
        
        for m in range(len(mos0_y_pos)):
            first_mov_pos=mos0_y_pos[m]
            last_mov_pos=mos0_y_pos[m-1]
            x = first_mov_pos - last_mov_pos
            mos0_y_dpos.append(x)
        
        for n in range(len(mos0_z_pos)):
            first_mov_pos=mos0_z_pos[n]
            last_mov_pos=mos0_z_pos[n-1]
            x = first_mov_pos - last_mov_pos
            mos0_z_dpos.append(x)

mos0_ids
mos0_dt
mos0_x_dpos 
mos0_y_dpos 
mos0_z_dpos       

time_pos=list(zip(mos0_ids, mos0_dt, mos0_x_dpos, mos0_y_dpos, mos0_z_dpos))                                                 
time_pos=pd.DataFrame(time_pos,columns=['mos_id','dtime', 'x_position', 'y_position','z_position'])               #  transform into a dataframe         
time_pos['x_velocity'] = time_pos['x_position']/time_pos['dtime']
time_pos['y_velocity'] = time_pos['y_position']/time_pos['dtime']
time_pos['z_velocity'] = time_pos['z_position']/time_pos['dtime']

time_pos['x_acceleration'] = time_pos['x_velocity']/time_pos['dtime']
time_pos['y_acceleration'] = time_pos['y_velocity']/time_pos['dtime']
time_pos['z_acceleration'] = time_pos['z_velocity']/time_pos['dtime']

time_pos=time_pos.groupby('mos_id') 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source