20230114
This commit is contained in:
1 parent
c1c1ad1842
commit
64d8cd5e16
1 file changed
+335
-35
+335
-35
@@ -723,27 +723,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 113,
|
"execution_count": null,
|
||||||
"id": "7bb2e3aa-591d-4fce-983a-cde5d4c30e56",
|
"id": "7bb2e3aa-591d-4fce-983a-cde5d4c30e56",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-09T13:24:29.720040Z",
|
|
||||||
"iopub.status.busy": "2023-01-09T13:24:29.719490Z",
|
|
||||||
"iopub.status.idle": "2023-01-09T13:24:30.627490Z",
|
|
||||||
"shell.execute_reply": "2023-01-09T13:24:30.626140Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-09T13:24:29.719971Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -784,27 +769,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 118,
|
"execution_count": null,
|
||||||
"id": "b38aef28-5d1b-4762-9c7e-70a531594fa4",
|
"id": "b38aef28-5d1b-4762-9c7e-70a531594fa4",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-09T13:32:31.923948Z",
|
|
||||||
"iopub.status.busy": "2023-01-09T13:32:31.923410Z",
|
|
||||||
"iopub.status.idle": "2023-01-09T13:32:32.253445Z",
|
|
||||||
"shell.execute_reply": "2023-01-09T13:32:32.252452Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-09T13:32:31.923900Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok!\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -842,10 +812,340 @@
|
|||||||
"print('ok!')"
|
"print('ok!')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "638bbe8e-3770-40e1-b884-ceeeec5a053c",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## 因素分析"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "9e25a7f2-0571-438b-9aa4-e3337d9fd840",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 清除修改测试项目"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 151,
|
||||||
|
"id": "6e6f6a63-b297-42e8-a9ba-b2636fda5d09",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T01:56:50.048701Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T01:56:50.047669Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T01:56:50.449993Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T01:56:50.448696Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T01:56:50.048628Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"code = '1734094'\n",
|
||||||
|
"items = ['身高','体重']\n",
|
||||||
|
"for item in items:\n",
|
||||||
|
" del dict1[code][item]\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(dict1, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "f96b3aeb-bf37-4a8b-bf18-d0ae8f7df653",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 人员情况导入"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 149,
|
||||||
|
"id": "4d77ec9b-c561-4355-98af-b18c42c1f3ca",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T01:56:10.352541Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T01:56:10.352010Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T01:56:13.111656Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T01:56:13.110214Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T01:56:10.352494Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import openpyxl\n",
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"wb = openpyxl.load_workbook('data/员工个人基础信息20230113.xlsx')\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"# sheets = wb.sheetnames\n",
|
||||||
|
"person = {}\n",
|
||||||
|
"\n",
|
||||||
|
"for n in range(4, sheet.max_row+1):\n",
|
||||||
|
" code = int(sheet.cell(n, 1).value)\n",
|
||||||
|
" person.setdefault(code, {})\n",
|
||||||
|
" dict1 = {}\n",
|
||||||
|
" dict1['name'] = sheet.cell(n, 2).value\n",
|
||||||
|
" dict1['sex'] = sheet.cell(n, 3).value\n",
|
||||||
|
" dict1['unit'] = sheet.cell(n, 6).value\n",
|
||||||
|
" dict1['sub_unit'] = sheet.cell(n, 7).value\n",
|
||||||
|
" if sheet.cell(n,10).value is not None:\n",
|
||||||
|
" dict1['daoban'] = '是'\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict1['daoban'] = '否'\n",
|
||||||
|
" dict1['age'] = sheet.cell(n, 13).value\n",
|
||||||
|
" dict1['gl'] = sheet.cell(n, 14).value\n",
|
||||||
|
" dict1['jhgl'] = sheet.cell(n, 15).value \n",
|
||||||
|
" person[code] = dict1\n",
|
||||||
|
"filename = 'data/天津石化人员231113.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "a5c58b77-69b6-4d76-8927-6e734556e848",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 人员体测得分导入合并"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 150,
|
||||||
|
"id": "db473c01-7e1a-48c4-a0d7-e44cdeb9e24b",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T01:56:24.524792Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T01:56:24.524267Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T01:56:24.967568Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T01:56:24.966212Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T01:56:24.524745Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_天津.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if k in dict1.keys():\n",
|
||||||
|
" for item in dict1[k].keys():\n",
|
||||||
|
" dict2[k][item] = dict1[k][item]\n",
|
||||||
|
"filename = 'data/天津石化人员231113.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(dict2, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')\n",
|
||||||
|
" "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "cc53ec68-cfc4-449a-9905-095a079dc8ab",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 筛选体测人员,计算得分"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 152,
|
||||||
|
"id": "224cdee4-153f-424a-aaaa-92ef58943edb",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T01:56:53.363160Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T01:56:53.362570Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T01:56:53.912576Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T01:56:53.911169Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T01:56:53.363112Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"ok\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"\n",
|
||||||
|
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/result_天津.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict2 = json.load(fl)\n",
|
||||||
|
"dict3 = {}\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if k in dict1.keys():\n",
|
||||||
|
" dict3[k] = dict2[k]\n",
|
||||||
|
" i = 0\n",
|
||||||
|
" score =0\n",
|
||||||
|
" for item in dict2[k].keys(): \n",
|
||||||
|
" if item in items:\n",
|
||||||
|
" score = score + int(dict2[k][item]['得分'])\n",
|
||||||
|
" i+=1\n",
|
||||||
|
" dict3[k]['score'] = score\n",
|
||||||
|
" dict3[k]['item_num'] = i\n",
|
||||||
|
" dict3[k]['avg'] = round(score/i,2)\n",
|
||||||
|
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||||
|
"with open(filename, 'w') as fl:\n",
|
||||||
|
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
||||||
|
"print('ok')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "dd014e41-18f2-44e7-9f20-1190df4e7b45",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### 因素分析"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "c63bca31-f003-49e9-a20d-1931c050c740",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 倒班因素分析"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 168,
|
||||||
|
"id": "2a964412-8408-4039-a788-8cc1fc7cd518",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T03:54:06.706899Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T03:54:06.706358Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T03:54:06.815555Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T03:54:06.814512Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T03:54:06.706851Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"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",
|
||||||
|
" dict2.setdefault(v['unit'],{})\n",
|
||||||
|
" dict2[v['unit']].setdefault('是',{})\n",
|
||||||
|
" dict2[v['unit']].setdefault('否',{})\n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('num',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('num',0)\n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('score',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('score',0)\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['num'] = dict2[v['unit']][v['daoban']]['num'] + 1\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['score'] = dict2[v['unit']][v['daoban']]['score'] + v['avg']\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" \n",
|
||||||
|
" if v['是']['num'] > 0:\n",
|
||||||
|
" dict2[k]['是']['avg'] = round(v['是']['score']/v['是']['num'],2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict2[k]['是']['avg'] = 0\n",
|
||||||
|
" if v['否']['num'] > 0:\n",
|
||||||
|
" dict2[k]['否']['avg'] = round(v['否']['score']/v['否']['num'],2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict2[k]['否']['avg'] = 0\n",
|
||||||
|
"list1 = [] \n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" unit = k\n",
|
||||||
|
" for k1, v1 in v.items():\n",
|
||||||
|
" daoban = k1\n",
|
||||||
|
" num = v1['num']\n",
|
||||||
|
" avg = v1['avg']\n",
|
||||||
|
" list2 = [k,daoban,num,avg]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
" \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",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "a4c24e30-f4e0-46e9-a22e-5460a73a14c8",
|
"id": "4fdc1484-ea69-4779-9a75-c52784cc9c7c",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user