sorting keyword dropdown and clicks graph
Browse files
app.py
CHANGED
|
@@ -181,7 +181,7 @@ def display_recommendations():
|
|
| 181 |
list_publisherid.append(keyword_publisherid.split("_")[1])
|
| 182 |
# list_keywords = ['aquaman', 'superman', 'batman', 'shoes', 'electronics', 'wallet', 'movies', 'books'] # Temporary
|
| 183 |
list_publisherid = ['725895'] # For the time being Publisher ID is being HardCoded.
|
| 184 |
-
selected_keyword = st.sidebar.selectbox("Select a Keyword:", set(list_keywords))
|
| 185 |
publisher_id = st.sidebar.selectbox("Select a Publisher ID:", set(list_publisherid))
|
| 186 |
|
| 187 |
# st.write(selected_keyword)
|
|
@@ -311,6 +311,8 @@ def display_analytics():
|
|
| 311 |
# Grouping the DataFrame
|
| 312 |
if column:
|
| 313 |
grouped_df = df.groupby([column]).sum().reset_index()
|
|
|
|
|
|
|
| 314 |
grouped_df.rename(columns={'count': 'clicks'}, inplace=True)
|
| 315 |
# st.dataframe(grouped_df.head())
|
| 316 |
col1, col2 = st.columns(2)
|
|
|
|
| 181 |
list_publisherid.append(keyword_publisherid.split("_")[1])
|
| 182 |
# list_keywords = ['aquaman', 'superman', 'batman', 'shoes', 'electronics', 'wallet', 'movies', 'books'] # Temporary
|
| 183 |
list_publisherid = ['725895'] # For the time being Publisher ID is being HardCoded.
|
| 184 |
+
selected_keyword = st.sidebar.selectbox("Select a Keyword:", set(list_keywords.sort()))
|
| 185 |
publisher_id = st.sidebar.selectbox("Select a Publisher ID:", set(list_publisherid))
|
| 186 |
|
| 187 |
# st.write(selected_keyword)
|
|
|
|
| 311 |
# Grouping the DataFrame
|
| 312 |
if column:
|
| 313 |
grouped_df = df.groupby([column]).sum().reset_index()
|
| 314 |
+
if column != 'date':
|
| 315 |
+
grouped_df = grouped_df.sort_values(by='count', ascending=False)
|
| 316 |
grouped_df.rename(columns={'count': 'clicks'}, inplace=True)
|
| 317 |
# st.dataframe(grouped_df.head())
|
| 318 |
col1, col2 = st.columns(2)
|