沥青定量添加月度数据测试通过
This commit is contained in:
parent
5e3389d5dd
commit
991a068bb6
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 11,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -192,8 +192,7 @@
|
||||
"\n",
|
||||
"def get_cur_time(date = ''):\n",
|
||||
" if date == '':\n",
|
||||
" import datetime\n",
|
||||
" now = datetime.datetime.now()\n",
|
||||
" now = datetime.now()\n",
|
||||
" else:\n",
|
||||
" now = date\n",
|
||||
" year = now.year\n",
|
||||
@ -545,6 +544,9 @@
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xls(append_rows)\n",
|
||||
" \n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" queryDataListItemNos(token)\n",
|
||||
" optimize_Model()\n",
|
||||
" upload_data_to_system(token_push)\n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
@ -582,8 +584,11 @@
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xls(append_rows)\n",
|
||||
" optimize_Model()\n",
|
||||
" upload_data_to_system(token_push,date)\n",
|
||||
"\n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" queryDataListItemNos(token)\n",
|
||||
" # optimize_Model()\n",
|
||||
" # upload_data_to_system(token_push,date)\n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
@ -786,7 +791,7 @@
|
||||
"\n",
|
||||
"def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
|
||||
"\n",
|
||||
" current_year_month = datetime.datetime.now().strftime('%Y-%m')\n",
|
||||
" current_year_month = datetime.now().strftime('%Y-%m')\n",
|
||||
" grouped = data_df.groupby(\"dataDate\")\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
@ -854,16 +859,19 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def queryDataListItemNos():\n",
|
||||
"def queryDataListItemNos(token=None):\n",
|
||||
" df = pd.read_excel('沥青数据项.xls')\n",
|
||||
" dataItemNoList = df.iloc[0].tolist()[1:]\n",
|
||||
" \n",
|
||||
" if token is None:\n",
|
||||
" token = get_head_auth()\n",
|
||||
"\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
" return\n",
|
||||
" if not token:\n",
|
||||
" print('token获取失败')\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # 获取当前日期\n",
|
||||
" current_date = datetime.datetime.now()\n",
|
||||
" current_date = datetime.now()\n",
|
||||
"\n",
|
||||
" # 获取当月1日\n",
|
||||
" first_day_of_month = current_date.replace(day=1)\n",
|
||||
@ -880,6 +888,7 @@
|
||||
" data_df[\"dataDate\"] = pd.to_datetime(data_df[\"dataDate\"])\n",
|
||||
" data_df[\"dataDate\"] = data_df[\"dataDate\"].dt.strftime('%Y-%m-%d')\n",
|
||||
" save_queryDataListItemNos_xls(data_df,dataItemNoList)\n",
|
||||
" print('当月数据更新完成')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
@ -894,8 +903,7 @@
|
||||
" # current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
" # current_time_1 = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
"\n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" # queryDataListItemNos()\n",
|
||||
"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" # # 判断当前时间是否为执行任务的时间点\n",
|
||||
@ -906,7 +914,7 @@
|
||||
" # 预测训练,\n",
|
||||
" # 预测结果上传\n",
|
||||
"\n",
|
||||
" # start()\n",
|
||||
" # start()\n",
|
||||
"\n",
|
||||
" # # 休眠1秒钟,避免过多占用CPU资源\n",
|
||||
" # time.sleep(1)\n",
|
||||
@ -926,14 +934,37 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20250401\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "PermissionError",
|
||||
"evalue": "[Errno 13] Permission denied: '沥青数据项.xls'",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mPermissionError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[12], line 11\u001b[0m\n\u001b[0;32m 9\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m start_date \u001b[38;5;241m<\u001b[39m end_date:\n\u001b[0;32m 10\u001b[0m \u001b[38;5;28mprint\u001b[39m(start_date\u001b[38;5;241m.\u001b[39mstrftime(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m'\u001b[39m))\n\u001b[1;32m---> 11\u001b[0m start_3(start_date,token,token_push)\n\u001b[0;32m 12\u001b[0m time\u001b[38;5;241m.\u001b[39msleep(\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 13\u001b[0m start_2(start_date,token)\n",
|
||||
"Cell \u001b[1;32mIn[11], line 553\u001b[0m, in \u001b[0;36mstart_3\u001b[1;34m(date, token, token_push)\u001b[0m\n\u001b[0;32m 551\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m 552\u001b[0m append_rows\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m--> 553\u001b[0m save_xls(append_rows)\n\u001b[0;32m 555\u001b[0m \u001b[38;5;66;03m# 获取当月的数据写入到指定文件\u001b[39;00m\n\u001b[0;32m 556\u001b[0m queryDataListItemNos(token)\n",
|
||||
"Cell \u001b[1;32mIn[11], line 731\u001b[0m, in \u001b[0;36msave_xls\u001b[1;34m(append_rows)\u001b[0m\n\u001b[0;32m 728\u001b[0m new_sheet\u001b[38;5;241m.\u001b[39mwrite(row_count, col, append_rows[col])\n\u001b[0;32m 730\u001b[0m \u001b[38;5;66;03m# 保存新的xls文件\u001b[39;00m\n\u001b[1;32m--> 731\u001b[0m new_workbook\u001b[38;5;241m.\u001b[39msave(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m沥青数据项.xls\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
||||
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\xlwt\\Workbook.py:710\u001b[0m, in \u001b[0;36mWorkbook.save\u001b[1;34m(self, filename_or_stream)\u001b[0m\n\u001b[0;32m 707\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01m.\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m CompoundDoc\n\u001b[0;32m 709\u001b[0m doc \u001b[38;5;241m=\u001b[39m CompoundDoc\u001b[38;5;241m.\u001b[39mXlsDoc()\n\u001b[1;32m--> 710\u001b[0m doc\u001b[38;5;241m.\u001b[39msave(filename_or_stream, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mget_biff_data())\n",
|
||||
"File \u001b[1;32m~\\AppData\\Roaming\\Python\\Python311\\site-packages\\xlwt\\CompoundDoc.py:262\u001b[0m, in \u001b[0;36mXlsDoc.save\u001b[1;34m(self, file_name_or_filelike_obj, stream)\u001b[0m\n\u001b[0;32m 260\u001b[0m we_own_it \u001b[38;5;241m=\u001b[39m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(f, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mwrite\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 261\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m we_own_it:\n\u001b[1;32m--> 262\u001b[0m f \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mopen\u001b[39m(file_name_or_filelike_obj, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw+b\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 263\u001b[0m f\u001b[38;5;241m.\u001b[39mwrite(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mheader)\n\u001b[0;32m 264\u001b[0m f\u001b[38;5;241m.\u001b[39mwrite(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mpacked_MSAT_1st)\n",
|
||||
"\u001b[1;31mPermissionError\u001b[0m: [Errno 13] Permission denied: '沥青数据项.xls'"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# from datetime import datetime, timedelta\n",
|
||||
"\n",
|
||||
"# start_date = datetime(2025, 2, 1)\n",
|
||||
"# end_date = datetime(2025, 3, 1)\n",
|
||||
"# start_date = datetime(2025, 4, 1)\n",
|
||||
"# end_date = datetime(2025, 4, 2)\n",
|
||||
"# token = get_head_auth()\n",
|
||||
"\n",
|
||||
"# token_push = get_head_push_auth()\n",
|
||||
@ -945,74 +976,6 @@
|
||||
"# start_2(start_date,token)\n",
|
||||
"# start_date += timedelta(days=1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19596\\1389844199.py:811: DeprecationWarning:\n",
|
||||
"\n",
|
||||
"The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
|
||||
"\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19596\\1389844199.py:302: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Using matplotlib backend: QtAgg\n",
|
||||
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
|
||||
"Populating the interactive namespace from numpy and matplotlib\n",
|
||||
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n",
|
||||
"Best score: 0.997\n",
|
||||
"Best parameters set:\n",
|
||||
"\tlearning_rate: 0.1\n",
|
||||
"\tmax_depth: 6\n",
|
||||
"\tn_estimators: 100\n",
|
||||
"日期\n",
|
||||
"2025-03-26 3627.309326\n",
|
||||
"Name: 日度预测价格, dtype: float32\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19596\\1389844199.py:242: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19596\\1389844199.py:276: FutureWarning:\n",
|
||||
"\n",
|
||||
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"3627.31"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"queryDataListItemNos()\n",
|
||||
"optimize_Model()\n",
|
||||
"forecast_price()"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user