Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dataframe.groupby instead of iterating #61

Merged
merged 17 commits into from
Dec 2, 2019
Merged
Prev Previous commit
Next Next commit
Fix mistake in row and column indexing
  • Loading branch information
Jack Valmadre committed Nov 29, 2019
commit 84487d73ffac2b54e6dedda2521592cb09b25db5
4 changes: 3 additions & 1 deletion motmetrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def id_global_assignment(df, ana = None):
#st1 = time.time()
oids = df.full['OId'].dropna().unique()
hids = df.full['HId'].dropna().unique()
oids_idx = dict((o,i) for i,o in enumerate(oids))
hids_idx = dict((h,i) for i,h in enumerate(hids))
#print('----'*2, '1', time.time()-st1)
flat = df.raw.reset_index()
Expand Down Expand Up @@ -514,7 +515,8 @@ def id_global_assignment(df, ana = None):
fpmatrix[c+no,c] = hc

#print('----'*2, '5', time.time()-st1)
for (r, c), ex in tpcs.items():
for (oid, hid), ex in tpcs.items():
r, c = oids_idx[oid], hids_idx[hid]
fpmatrix[r,c] -= ex
fnmatrix[r,c] -= ex

Expand Down