BERTopic icon indicating copy to clipboard operation
BERTopic copied to clipboard

Update multimodal.md to add axis keyword [Issue #1884]

Open mepearson opened this issue 11 months ago • 1 comments

Update Multimodal documentation to add an axis keyword for the drop function. This addresses issue #1884

Existing Code:

# Extract dataframe
df = topic_model.get_topic_info().drop("Representative_Docs", 1).drop("Name", 1)

Suggested Code:

# Extract dataframe  
df = topic_model.get_topic_info().drop(["Representative_Docs","Name"], axis=1)

This corrects the following error caused by the need for keyword arguments in newer versions of pandas. Columns to drop were gathered into a single list just for simplicity.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[12], line 1
----> 1 df.drop("Representative_Docs", 1).drop("Name", 1)

TypeError: DataFrame.drop() takes from 1 to 2 positional arguments but 3 were given

mepearson avatar Mar 22 '24 17:03 mepearson

Thanks for the PR! Do you know why this change is necessary? The reason why I ask is that this might relate to specific versions of pandas as this piece of code did work before. Did you test this?

MaartenGr avatar Mar 24 '24 07:03 MaartenGr