20230214
This commit is contained in:
1 parent
afdeae1fee
commit
af381a716e
1 file changed
+95
-1
+95
-1
@@ -1344,10 +1344,104 @@
|
||||
"print('ok!')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "42e4ef5b-9aa8-4098-8f33-df9787dd34ab",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"#### 倒班时间因素分析"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "255b5649-fb85-424d-9fad-0f3e1dff2be3",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-02-14T14:30:30.331426Z",
|
||||
"iopub.status.busy": "2023-02-14T14:30:30.330830Z",
|
||||
"iopub.status.idle": "2023-02-14T14:30:30.441098Z",
|
||||
"shell.execute_reply": "2023-02-14T14:30:30.440041Z",
|
||||
"shell.execute_reply.started": "2023-02-14T14:30:30.331376Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"{2: {'num': 571, 'score': 1619.279999999999, 'zhongyi': 55, 'pianpo': 44}, 3: {'num': 665, 'score': 1730.73, 'zhongyi': 76, 'pianpo': 62}, 1: {'num': 129, 'score': 358.9600000000001, 'zhongyi': 23, 'pianpo': 19}, 0: {'num': 706, 'score': 1963.300000000001, 'zhongyi': 70, 'pianpo': 32}, 4: {'num': 81, 'score': 194.23999999999992, 'zhongyi': 17, 'pianpo': 14}}\n",
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"unit = set()\n",
|
||||
"\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" unit.add(dict1[k]['unit'])\n",
|
||||
"#print(unit)\n",
|
||||
"dict2 = {}\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if v['daoban'] == '是':\n",
|
||||
" \n",
|
||||
" gld = int(int(v['gl'])/10)\n",
|
||||
" dict2.setdefault(gld,{}) \n",
|
||||
" dict2[gld].setdefault('num',0)\n",
|
||||
" dict2[gld].setdefault('score',0)\n",
|
||||
" dict2[gld].setdefault('zhongyi',0)\n",
|
||||
" dict2[gld].setdefault('pianpo',0) \n",
|
||||
" if 'avg' in v.keys():\n",
|
||||
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||||
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||||
" if 'zhongyi' in v.keys() :\n",
|
||||
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||||
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||||
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||||
"print(dict2)\n",
|
||||
"nl = {}\n",
|
||||
"nl[0] = '倒班工龄0-9年'\n",
|
||||
"nl[1] = '倒班工龄10-19年'\n",
|
||||
"nl[2] = '倒班工龄20-29年'\n",
|
||||
"nl[3] = '倒班工龄30-39年'\n",
|
||||
"nl[4] = '倒班工龄40-49年'\n",
|
||||
"list1 = [] \n",
|
||||
"for k, v in nl.items():\n",
|
||||
" list2 = []\n",
|
||||
" gld = v\n",
|
||||
" \n",
|
||||
" num = dict2[k]['num']\n",
|
||||
" score = dict2[k]['score']\n",
|
||||
" if num > 0:\n",
|
||||
" avg = round(score/num,2)\n",
|
||||
" else:\n",
|
||||
" avg = 0\n",
|
||||
" zhongyi = dict2[k]['zhongyi']\n",
|
||||
" pianpo = dict2[k]['pianpo']\n",
|
||||
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/天津倒班因素分析表(倒班工龄).xlsx' \n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"\n",
|
||||
"for row in list1:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename)\n",
|
||||
"print('ok!')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "93ae7587-e49d-41c2-bd57-f89b9eed37e4",
|
||||
"id": "683297cb-709a-40e1-a07f-59cf2cf8655b",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user