Arafath10 commited on
Commit
fbd8c25
1 Parent(s): 5409f6f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -2
main.py CHANGED
@@ -175,6 +175,9 @@ def process_product(product_name, data):
175
  # Concatenate the original DataFrame with the new fake transaction DataFrame
176
  data = pd.concat([data, fake_transaction_df], ignore_index=True)
177
 
 
 
 
178
  # Summarize the sales count per month
179
  data['transaction_date'] = pd.to_datetime(data['transaction_date'])
180
  data.set_index('transaction_date', inplace=True)
@@ -186,6 +189,7 @@ def process_product(product_name, data):
186
  result_dict = rounded_value.to_dict(orient="records")[0]
187
 
188
  return {
 
189
  "Product Name": product_name,
190
  "next_month": str(result_dict["next_month"]),
191
  "predicted_count": result_dict["predicted_count"]
@@ -193,6 +197,7 @@ def process_product(product_name, data):
193
  }
194
  except Exception as e:
195
  return {
 
196
  "Product Name": product_name,
197
  "next_month": str(e),
198
  "predicted_count": "not predicted"
@@ -215,8 +220,10 @@ async def generate_product_count_prediction(b_id: int):
215
  for future in as_completed(futures):
216
  results.append(future.result())
217
 
218
-
219
- delete_json(b_id)
 
 
220
  insert_data(b_id,results)
221
  return {"status": "success",
222
  "b_id":b_id,
 
175
  # Concatenate the original DataFrame with the new fake transaction DataFrame
176
  data = pd.concat([data, fake_transaction_df], ignore_index=True)
177
 
178
+ # Extract the 'sub_sku' column
179
+ sub_sku = df['sub_sku']
180
+
181
  # Summarize the sales count per month
182
  data['transaction_date'] = pd.to_datetime(data['transaction_date'])
183
  data.set_index('transaction_date', inplace=True)
 
189
  result_dict = rounded_value.to_dict(orient="records")[0]
190
 
191
  return {
192
+ "sub_sku": sub_sku,
193
  "Product Name": product_name,
194
  "next_month": str(result_dict["next_month"]),
195
  "predicted_count": result_dict["predicted_count"]
 
197
  }
198
  except Exception as e:
199
  return {
200
+ "sub_sku": sub_sku,
201
  "Product Name": product_name,
202
  "next_month": str(e),
203
  "predicted_count": "not predicted"
 
220
  for future in as_completed(futures):
221
  results.append(future.result())
222
 
223
+ try:
224
+ delete_json(b_id)
225
+ except:
226
+ print("no errors")
227
  insert_data(b_id,results)
228
  return {"status": "success",
229
  "b_id":b_id,