Skip to content

Commit

Permalink
Fix from_items AttributeError in algo/graph/mixin_groundtruth.py
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
karenc authored and bluemellophone committed Aug 11, 2020
1 parent 0cdd92d commit 6cd8bea
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions wbia/algo/graph/mixin_groundtruth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,14 @@ def match_state_df(infr, index):
aid_pairs = vt.ensure_shape(aid_pairs, (None, 2))
is_same = infr.is_same(aid_pairs)
is_comp = infr.is_comparable(aid_pairs)
match_state_df = pd.DataFrame.from_items(
[(NEGTV, ~is_same & is_comp), (POSTV, is_same & is_comp), (INCMP, ~is_comp)]
match_state_df = pd.DataFrame.from_dict(
dict(
[
(NEGTV, ~is_same & is_comp),
(POSTV, is_same & is_comp),
(INCMP, ~is_comp),
]
)
)
match_state_df.index = index
return match_state_df
Expand Down

0 comments on commit 6cd8bea

Please sign in to comment.