Mattral commited on
Commit
e8669e6
·
verified ·
1 Parent(s): 8bb6881

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -477,11 +477,14 @@ df.drop(columns={col_to_delete}, inplace=True)
477
  text_data = ' '.join(df[text_col].dropna()).strip()
478
 
479
  if text_data: # Check if there is any text data to use
480
- wordcloud = WordCloud(width=800, height=400).generate(text_data)
481
- fig, ax = plt.subplots()
482
- ax.imshow(wordcloud, interpolation='bilinear')
483
- ax.axis('off')
484
- st.pyplot(fig)
 
 
 
485
  else:
486
  st.error("No words available to create a word cloud. Please check the selected text data.")
487
  else:
 
477
  text_data = ' '.join(df[text_col].dropna()).strip()
478
 
479
  if text_data: # Check if there is any text data to use
480
+ try:
481
+ wordcloud = WordCloud(width=800, height=400).generate(text_data)
482
+ fig, ax = plt.subplots()
483
+ ax.imshow(wordcloud, interpolation='bilinear')
484
+ ax.axis('off')
485
+ st.pyplot(fig)
486
+ except ValueError as e:
487
+ st.error("Failed to generate word cloud: " + str(e))
488
  else:
489
  st.error("No words available to create a word cloud. Please check the selected text data.")
490
  else: