Roberta2024 commited on
Commit
47addb2
·
verified ·
1 Parent(s): 031b1c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -76,6 +76,20 @@ if st.button("開始搜索"):
76
  if not pchome_data.empty:
77
  st.write("PCHOME 商品數據:", pchome_data)
78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  # Google Trends Analysis
80
  pytrend = TrendReq(hl="zh-TW", tz=-480)
81
  time_range = f'{start_date} {end_date}'
@@ -131,7 +145,6 @@ if st.button("開始搜索"):
131
 
132
  # Pie Chart based on prices
133
  if not momo_df.empty or not pchome_data.empty:
134
- combined_df = pd.concat([momo_df, pchome_data])
135
  pie_fig = go.Figure(go.Pie(
136
  labels=combined_df['title'],
137
  values=combined_df['price'],
 
76
  if not pchome_data.empty:
77
  st.write("PCHOME 商品數據:", pchome_data)
78
 
79
+ # Combine MOMO and PCHOME data
80
+ combined_df = pd.concat([momo_df, pchome_data])
81
+
82
+ # Sort the combined data by price
83
+ sorted_combined_df = combined_df.sort_values(by='price', ascending=True)
84
+
85
+ # Display sorted data
86
+ if not sorted_combined_df.empty:
87
+ st.write("所有商品的價格 (從低到高排序):", sorted_combined_df)
88
+
89
+ # Add a button to download the data as CSV
90
+ csv = sorted_combined_df.to_csv(index=False)
91
+ st.download_button(label="下載 CSV 檔案", data=csv, file_name=f'{search_keyword}_price_data.csv', mime='text/csv')
92
+
93
  # Google Trends Analysis
94
  pytrend = TrendReq(hl="zh-TW", tz=-480)
95
  time_range = f'{start_date} {end_date}'
 
145
 
146
  # Pie Chart based on prices
147
  if not momo_df.empty or not pchome_data.empty:
 
148
  pie_fig = go.Figure(go.Pie(
149
  labels=combined_df['title'],
150
  values=combined_df['price'],