Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,7 +104,7 @@ def generate_bar_chart(df, num_clusters_to_display):
|
|
| 104 |
top_clusters = df['Cluster'].value_counts().index[1:num_clusters_to_display+1]
|
| 105 |
df_top_clusters = df[df['Cluster'].isin(top_clusters)]
|
| 106 |
|
| 107 |
-
cluster_top_words = df_top_clusters.groupby('Cluster')['texts'].apply(lambda x: ' '.join(x)).reset_index()
|
| 108 |
cluster_top_words['top_word'] = cluster_top_words['texts'].apply(lambda x: pd.Series(x.split()).value_counts().index[0] if len(x.split()) > 0 else '')
|
| 109 |
cluster_sizes = df_top_clusters['Cluster'].value_counts().reset_index()
|
| 110 |
cluster_sizes.columns = ['Cluster', 'Count']
|
|
|
|
| 104 |
top_clusters = df['Cluster'].value_counts().index[1:num_clusters_to_display+1]
|
| 105 |
df_top_clusters = df[df['Cluster'].isin(top_clusters)]
|
| 106 |
|
| 107 |
+
cluster_top_words = df_top_clusters.groupby('Cluster', observed=False)['texts'].apply(lambda x: ' '.join(x)).reset_index()
|
| 108 |
cluster_top_words['top_word'] = cluster_top_words['texts'].apply(lambda x: pd.Series(x.split()).value_counts().index[0] if len(x.split()) > 0 else '')
|
| 109 |
cluster_sizes = df_top_clusters['Cluster'].value_counts().reset_index()
|
| 110 |
cluster_sizes.columns = ['Cluster', 'Count']
|