How to merge duplicates in 2D python arrays

Posted by Wei Lou on Stack Overflow See other posts from Stack Overflow or by Wei Lou
Published on 2009-11-18T21:55:07Z Indexed on 2010/06/05 10:02 UTC
Read the original article Hit count: 298

Filed under:
|
|
|

Hi, I have a set of data similar to this:

No Start Time End Time CallType Info 
1 13:14:37.236 13:14:53.700 Ping1  RTT(Avr):160ms
2 13:14:58.955 13:15:29.984 Ping2  RTT(Avr):40ms
3 13:19:12.754 13:19:14.757 Ping3_1  RTT(Avr):620ms
3 13:19:12.754          Ping3_2  RTT(Avr):210ms
4 13:14:58.955 13:15:29.984 Ping4  RTT(Avr):360ms
5 13:19:12.754 13:19:14.757 Ping1  RTT(Avr):40ms
6 13:19:59.862 13:20:01.522 Ping2  RTT(Avr):163ms
...

when i parse through it, i need merge the results of Ping3_1 and Ping3_2. Then take average of those two row export as one row. So the end of result would be like this:

No Start Time End Time CallType Info 
1 13:14:37.236 13:14:53.700 Ping1  RTT(Avr):160ms
2 13:14:58.955 13:15:29.984 Ping2  RTT(Avr):40ms
3 13:19:12.754 13:19:14.757 Ping3  RTT(Avr):415ms
4 13:14:58.955 13:15:29.984 Ping4  RTT(Avr):360ms
5 13:19:12.754 13:19:14.757 Ping1  RTT(Avr):40ms
6 13:19:59.862 13:20:01.522 Ping2  RTT(Avr):163ms

currently i am concatenating column 0 and 1 to make a unique key, find duplication there then doing rest of special treatment for those parallel Pings. It is not elegant at all. Just wonder what is the better way to do it. Thanks!

© Stack Overflow or respective owner

Related posts about python

Related posts about arrays