Skip to content

Commit

Permalink
Merge pull request #18 from selimelawwa/add_world_clouds
Browse files Browse the repository at this point in the history
Initial commit to support world-clouds visualization
  • Loading branch information
jbesomi authored May 10, 2020
2 parents cd3e04c + 6f5bb0b commit c00f1dc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ nltk
scikit-learn
plotly_express
spacy
wordcloud
25 changes: 24 additions & 1 deletion texthero/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd
import plotly.express as px

from wordcloud import WordCloud

def scatterplot(df: pd.DataFrame,
col: str,
Expand Down Expand Up @@ -38,6 +38,29 @@ def scatterplot(df: pd.DataFrame,
if return_figure:
return fig

def wordcloud(s: pd.Series,
title="",
return_figure=False):
"""
Show wordcloud using WordCloud.
Parameters
----------
df
col
The name of the column of the DataFrame containing the text data.
"""
text = s.str.cat(sep=' ')

wordcloud = WordCloud(background_color ='white', min_font_size = 10).generate(text)

fig = px.imshow(wordcloud, title=title)
fig.show()

if return_figure:
return fig


def top_words(s: pd.Series, normalize=False) -> pd.Series:
"""
Expand Down

0 comments on commit c00f1dc

Please sign in to comment.