Most efficient way of conditional pairwise row operations in a pandas DataFrame

129 Views Asked by At

I have a pandas DataFrame 'df' containing about 106 rows. Now I want to execute the following code:

c = []
for ind, a in df.iterrows():
    for ind, b in df.iterrows():
        if a.hit_id < b.hit_id and a.layer_id != b.layer_id :
            c.append(dist(a, b))
c = numpy.array(c)

What is the most efficient way of doing this?

0

There are 0 best solutions below