Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
|
|
|
|
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 |
-
|
492 |
-
|
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 |
|