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

TypeError: to_dict() takes from 1 to 2 positional arguments but 4 were given #269

Open
pztvve opened this issue May 21, 2024 · 1 comment

Comments

@pztvve
Copy link

pztvve commented May 21, 2024

excuse me, can i solve this??

pyLDAvis.enable_notebook() vis = pyLDAvis.gensim_models.prepare(ldamodel, corpus, dictionary) pyLDAvis.display(vis)

and the error got like this👇

TypeError Traceback (most recent call last)
/var/folders/_t/3y_grysj66102pr90s1sgnkh0000gn/T/ipykernel_23220/4280233777.py in ?()
1 pyLDAvis.enable_notebook()
2 vis = pyLDAvis.gensim_models.prepare(ldamodel, corpus, dictionary)
----> 3 pyLDAvis.display(vis)

/opt/anaconda3/lib/python3.11/site-packages/pyLDAvis/_display.py in ?(data, local, **kwargs)
218 warnings.warn(
219 "display: specified urls are ignored when local=True")
220 kwargs['d3_url'], kwargs['ldavis_url'], kwargs['ldavis_css_url'] = write_ipynb_local_js()
221
--> 222 return HTML(prepared_data_to_html(data, **kwargs))

/opt/anaconda3/lib/python3.11/site-packages/pyLDAvis/_display.py in ?(data, d3_url, ldavis_url, ldavis_css_url, template_type, visid, use_http)
173 return template.render(visid=json.dumps(visid),
174 visid_raw=visid,
175 d3_url=d3_url,
176 ldavis_url=ldavis_url,
--> 177 vis_json=data.to_json(),
178 ldavis_css_url=ldavis_css_url)

/opt/anaconda3/lib/python3.11/site-packages/pyLDAvis/_prepare.py in ?(self)
463 def to_json(self):
--> 464 return json.dumps(self.to_dict(), cls=NumPyEncoder)

/opt/anaconda3/lib/python3.11/site-packages/pyLDAvis/_prepare.py in ?(self)
454 def to_dict(self):
--> 455 return {'mdsDat': self.topic_coordinates.to_dict(orient='list'),
456 'tinfo': self.topic_info.to_dict(orient='list'),
457 'token.table': self.token_table.to_dict(orient='list'),
458 'R': self.R,

/opt/anaconda3/lib/python3.11/site-packages/pandas/core/frame.py in ?(self, orient, into, index)
2035 UserWarning,
2036 stacklevel=find_stack_level(),
2037 )
2038 # GH16122
-> 2039 into_c = com.standardize_mapping(into)
2040
2041 # error: Incompatible types in assignment (expression has type "str",
2042 # variable has type "Literal['dict', 'list', 'series', 'split', 'tight',

TypeError: to_dict() takes from 1 to 2 positional arguments but 4 were given

i tried every version

@msusol
Copy link
Collaborator

msusol commented May 21, 2024

I am not able to reproduce the error using the https://github.com/bmabey/pyLDAvis/blob/master/notebooks/Gensim%20Newsgroup.ipynb notebook with the following codeblock (lda -> ldamodel)

from pyLDAvis import gensim_models
import pyLDAvis

pyLDAvis.enable_notebook()
vis_data = gensim_models.prepare(lda, corpus, dictionary)
pyLDAvis.display(vis_data)

can you run this notebook without error?
https://github.com/bmabey/pyLDAvis/blob/master/notebooks/Gensim%20Newsgroup.ipynb

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

2 participants