Skip to content

Commit 6cd8bea

Browse files
karencbluemellophone
authored andcommitted
Fix from_items AttributeError in algo/graph/mixin_groundtruth.py
When running the test `wbia/algo/graph/refresh.py::demo_refresh:0`: ``` Traceback (most recent call last): File "/virtualenv/env3/lib/python3.6/site-packages/xdoctest/doctest_example.py", line 556, in run exec(code, test_globals) File "<doctest:/wbia/wildbook-ia/wbia/algo/graph/refresh.py::demo_refresh:0>", line rel: 3, abs: 218, in <module> >>> demo_refresh() File "/wbia/wildbook-ia/wbia/algo/graph/refresh.py", line 232, in demo_refresh ys = infr.match_state_df(edges)[POSTV].values File "/wbia/wildbook-ia/wbia/algo/graph/mixin_groundtruth.py", line 56, in match_state_df match_state_df = pd.DataFrame.from_items( AttributeError: type object 'DataFrame' has no attribute 'from_items' ``` Looking at the panda changelog, it seems `from_items` was removed in `v1.0.0` and replaced by `from_dict`. See pandas-dev/pandas#18529.
1 parent 0cdd92d commit 6cd8bea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

wbia/algo/graph/mixin_groundtruth.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,14 @@ def match_state_df(infr, index):
5252
aid_pairs = vt.ensure_shape(aid_pairs, (None, 2))
5353
is_same = infr.is_same(aid_pairs)
5454
is_comp = infr.is_comparable(aid_pairs)
55-
match_state_df = pd.DataFrame.from_items(
56-
[(NEGTV, ~is_same & is_comp), (POSTV, is_same & is_comp), (INCMP, ~is_comp)]
55+
match_state_df = pd.DataFrame.from_dict(
56+
dict(
57+
[
58+
(NEGTV, ~is_same & is_comp),
59+
(POSTV, is_same & is_comp),
60+
(INCMP, ~is_comp),
61+
]
62+
)
5763
)
5864
match_state_df.index = index
5965
return match_state_df

0 commit comments

Comments
 (0)