Update 'Demand_forcasting/forcasting.py'
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
from flask import Flask, render_template, send_file, request, redirect, Response
|
||||
import os
|
||||
|
||||
|
||||
import pandas as pd
|
||||
import warnings
|
||||
import json
|
||||
@@ -9,10 +7,6 @@ import requests
|
||||
from urllib.request import urlopen
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
@@ -317,13 +311,14 @@ def month(Num,df):
|
||||
|
||||
#df1=pd.read_csv(r'./upload/' + name)
|
||||
#df1=df1[df1['obdate']!='01/01/0001']
|
||||
userdata.columns = ['itemname','sum','journaldate','itemid']
|
||||
#userdata.columns = ['itemname','sum','journaldate','itemid']
|
||||
userdata.columns = ['journaldate','sum','itemid','itemname']
|
||||
# import pandas as pd
|
||||
# userdata = pd.read_csv(r'C:\Users\Bizga\Desktop\forcast\5yearsitems.csv')
|
||||
# itemid = userdata[['itemname', 'itemid']]
|
||||
#userdata['journaldate'] = pd.to_datetime(userdata['journaldate'])
|
||||
userdata["journaldate"] = userdata["journaldate"].astype(str)
|
||||
userdata[["year", "month", "day"]] = userdata["journaldate"].str.split("-", expand = True)
|
||||
userdata[["day","month","year"]] = userdata["journaldate"].str.split("-", expand = True)
|
||||
userdata['Month-Year']=userdata['year'].astype(str)+'-'+userdata['month'].astype(str)
|
||||
item_unique_name = userdata['itemname'].unique()
|
||||
|
||||
@@ -495,6 +490,33 @@ def month(Num,df):
|
||||
result['LowerLimit']=result['Predict'].mean()-result['Predict'].std()*3
|
||||
result["LowerLimit"][result["LowerLimit"] < 0] = 0
|
||||
print(result)
|
||||
# frames = [fulldata, result]
|
||||
|
||||
# final = pd.concat(frames)
|
||||
# print('********************************************************')
|
||||
# final['itemname'] = item
|
||||
# final['itemid'] =item_id
|
||||
# final.columns = ['Date','Predict','ItemName','ItemId']
|
||||
# final['upper_limit']=final["Predict"]+final['Predict']*0.2
|
||||
# # final['lower_limit']=final['Predict']-final['Predict']*0.2
|
||||
# # print(final)
|
||||
# # final.to_json('forcast.json', orient="records")
|
||||
|
||||
# with open('forcast.json', 'r') as json_file:
|
||||
# json_load = json.load(json_file)
|
||||
# #url = "https://demo.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List"
|
||||
# url='https://qa.bizgaze.app/apis/v4/bizgaze/integrations/demandforecast/saveforecast/List'
|
||||
|
||||
# payload = json.dumps(json_load)#.replace("]", "").replace("[", "")
|
||||
# print(payload)
|
||||
# headers = {
|
||||
# #'Authorization': 'stat 263162e61f084d3392f162eb7ec39b2c',#demo
|
||||
# 'Authorization': 'stat 873f2e6f70b3483e983972f96fbf5ea4',#test
|
||||
# 'Content-Type': 'application/json'
|
||||
# }
|
||||
# response = requests.request("POST", url, headers=headers, data=payload)
|
||||
# print("##############################################################")
|
||||
# print(response.text)
|
||||
|
||||
filePath='path.csv'
|
||||
|
||||
@@ -574,6 +596,7 @@ def sales_forcast():
|
||||
#print(Dataset)
|
||||
import pandas as pd
|
||||
df=pd.DataFrame(Dataset)
|
||||
#df=pd.read_csv('ItemWiseQuantity_STC.csv')
|
||||
print(df)
|
||||
# a = Dataset
|
||||
#x = a['wise']
|
||||
@@ -601,7 +624,7 @@ def sales_forcast():
|
||||
# import json
|
||||
# a={"status":"success"}
|
||||
# payload123 = json.dumps(a)
|
||||
return output
|
||||
return "done"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host='0.0.0.0', port=8082)
|
||||
Reference in New Issue
Block a user