Mattral commited on
Commit
6746f85
·
verified ·
1 Parent(s): b8b67a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -481,15 +481,17 @@ df.drop(columns={col_to_delete}, inplace=True)
481
  if st.checkbox("Show Word Cloud", value=False):
482
  text_col = st.selectbox("Select Text Column for Word Cloud", options=df.select_dtypes(include=[np.object]).columns.tolist())
483
  text_data = ' '.join(df[text_col].dropna()).strip() # Collect and strip the text data
484
-
485
- if text_data: # Check if there is any text data
 
 
486
  wordcloud = WordCloud(width=800, height=400).generate(text_data)
487
  fig, ax = plt.subplots()
488
  ax.imshow(wordcloud, interpolation='bilinear')
489
  ax.axis('off')
490
  st.pyplot(fig)
491
- else:
492
- st.write("No words available to create a word cloud.")
493
 
494
 
495
 
 
481
  if st.checkbox("Show Word Cloud", value=False):
482
  text_col = st.selectbox("Select Text Column for Word Cloud", options=df.select_dtypes(include=[np.object]).columns.tolist())
483
  text_data = ' '.join(df[text_col].dropna()).strip() # Collect and strip the text data
484
+
485
+ if not text_col and text_data:
486
+ st.error("No words available to create a word cloud.")
487
+ elif text_data: # Check if there is any text data
488
  wordcloud = WordCloud(width=800, height=400).generate(text_data)
489
  fig, ax = plt.subplots()
490
  ax.imshow(wordcloud, interpolation='bilinear')
491
  ax.axis('off')
492
  st.pyplot(fig)
493
+ else:
494
+ st.write("No words available to create a word cloud.")
495
 
496
 
497