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

AttributeError: module 'recordlinkage' has no attribute 'Index' #25

Closed
boscoraju opened this issue Sep 12, 2016 · 2 comments
Closed

AttributeError: module 'recordlinkage' has no attribute 'Index' #25

boscoraju opened this issue Sep 12, 2016 · 2 comments

Comments

@boscoraju
Copy link

Hi @J535D165,

I am trying to run the example provided but I am running into an error about no attribute "index".

index = recordlinkage.Index(df_a, df_b)


index = recordlinkage.Index(df_a, df_b)
AttributeError: module 'recordlinkage' has no attribute 'Index'

Any help is much appreciated. Thank you.

@J535D165
Copy link
Owner

J535D165 commented Sep 12, 2016

Hello boscoraju,

I'm sorry for this stupid mistake. Use index = recordlinkage.Pairs(df_a, df_b) instead.

Index was used in an old version. It was confusing with the pandas.Index in the pandas API and therefore renamed.

For more docs: http://recordlinkage.readthedocs.io/en/latest/notebooks/link_two_dataframes.html

Good luck.

@froukehe9
Copy link

froukehe9 commented Oct 7, 2019

I've tried changing it to Pairs, but now have a problem with the index line from the example:

politie_sample = politie_sel.sample(frac = 0.001)
lbz_sample = lbz_sel.sample(frac = 0.001)

indexer = recordlinkage.Pairs(politie_sample, lbz_sample)
indexer.block('Gender')
candidate_links = indexer.index(politie_sample, lbz_sample)

Traceback (most recent call last):

. File "", line 6, in
candidate_links = indexer.index(politie_sample, lbz_sample)

File "C:\Anaconda3\lib\site-packages\recordlinkage\indexing.py", line 330, in index
d = next(self._iterindex(index_func, *args, **kwargs))

File "C:\Anaconda3\lib\site-packages\recordlinkage\indexing.py", line 483, in _iterindex
*args, **kwargs

TypeError: 'DataFrame' object is not callable

I've then tried to call the last line without data-frames as arguments, but then can't compute the length:

Traceback (most recent call last):

File "", line 1, in
len(candidate_links)

TypeError: object of type 'method' has no len()

When I then try to use the Compare function (it asks for an argument, so I supplied the indexer object), I get the following error message:

compare_cl = recordlinkage.Compare(indexer)
compare_cl.exact('Gender', 'Gender', label='Gender')
Traceback (most recent call last):

File "", line 1, in
compare_cl = recordlinkage.Compare(indexer)

File "C:\Anaconda3\lib\site-packages\recordlinkage\comparing.py", line 86, in init
self.vectors = pandas.DataFrame(index=pairs)

File "C:\Anaconda3\lib\site-packages\pandas\core\frame.py", line 266, in init
mgr = self._init_dict(data, index, columns, dtype=dtype)

File "C:\Anaconda3\lib\site-packages\pandas\core\frame.py", line 402, in _init_dict
return _arrays_to_mgr(arrays, data_names, index, columns, dtype=dtype)

File "C:\Anaconda3\lib\site-packages\pandas\core\frame.py", line 5411, in _arrays_to_mgr
index = _ensure_index(index)

File "C:\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 3665, in _ensure_index
return Index(index_like)

File "C:\Anaconda3\lib\site-packages\pandas\indexes\base.py", line 312, in new
subarr = _asarray_tuplesafe(data, dtype=object)

File "C:\Anaconda3\lib\site-packages\pandas\core\common.py", line 369, in _asarray_tuplesafe
values = list(values)

TypeError: 'Pairs' object is not iterable

Is there a way to go back to the original Index function?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants