From 7200d7334ce967a7591f6fb4e0e2cc2b88132873 Mon Sep 17 00:00:00 2001 From: 512song Date: Sun, 28 May 2023 00:11:39 +0800 Subject: [PATCH] 20230528 --- 体测单位/燕山石化.ipynb | 1539 +++++++++++++++++++++++++++++++------ 体测单位/石家庄石化.ipynb | 23 +- 体测单位/长炼医院.ipynb | 138 +++- 文件操作.ipynb | 16 +- 4 files changed, 1458 insertions(+), 258 deletions(-) diff --git a/体测单位/燕山石化.ipynb b/体测单位/燕山石化.ipynb index 035fee2..084d4eb 100644 --- a/体测单位/燕山石化.ipynb +++ b/体测单位/燕山石化.ipynb @@ -10,30 +10,12 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "id": "1b92b7c5-cb77-49da-95b7-34827ecf1d16", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-25T05:10:51.673096Z", - "iopub.status.busy": "2023-05-25T05:10:51.672189Z", - "iopub.status.idle": "2023-05-25T05:10:53.934382Z", - "shell.execute_reply": "2023-05-25T05:10:53.933611Z", - "shell.execute_reply.started": "2023-05-25T05:10:51.673057Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "8208\n", - "8208\n", - "8208\n", - "ok\n" - ] - } - ], + "outputs": [], "source": [ "import openpyxl\n", "import json\n", @@ -106,30 +88,12 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "71e1ec6a-6797-4496-969a-1d1461b9ea58", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-17T08:58:25.400000Z", - "iopub.status.busy": "2023-05-17T08:58:25.399131Z", - "iopub.status.idle": "2023-05-17T08:58:25.810982Z", - "shell.execute_reply": "2023-05-17T08:58:25.810241Z", - "shell.execute_reply.started": "2023-05-17T08:58:25.399960Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "133\n", - "2004 刘鹏 已测试!\n", - "133\n", - "7730\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import time\n", @@ -202,16 +166,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "id": "c24880ad-bbbd-4ad8-a894-cbcea389e822", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-17T09:00:37.129834Z", - "iopub.status.busy": "2023-05-17T09:00:37.129418Z", - "iopub.status.idle": "2023-05-17T09:00:37.212119Z", - "shell.execute_reply": "2023-05-17T09:00:37.211419Z", - "shell.execute_reply.started": "2023-05-17T09:00:37.129806Z" - }, "tags": [] }, "outputs": [], @@ -267,16 +224,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "id": "79c9c728-12e9-4107-bc5a-8c3e3d8b64a6", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-18T12:37:39.026994Z", - "iopub.status.busy": "2023-05-18T12:37:39.026072Z", - "iopub.status.idle": "2023-05-18T12:37:41.214470Z", - "shell.execute_reply": "2023-05-18T12:37:41.213773Z", - "shell.execute_reply.started": "2023-05-18T12:37:39.026953Z" - }, "tags": [] }, "outputs": [], @@ -332,27 +282,12 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": null, "id": "68454877-f1fe-4eed-8a48-265e428f892e", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-16T08:37:50.893472Z", - "iopub.status.busy": "2023-05-16T08:37:50.892954Z", - "iopub.status.idle": "2023-05-16T08:37:50.917547Z", - "shell.execute_reply": "2023-05-16T08:37:50.916456Z", - "shell.execute_reply.started": "2023-05-16T08:37:50.893441Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'储运厂工会': 9, '热电厂工会': 65, '炼油厂工会': 48, '合成橡胶厂工会': 31, '检验计量中心工会': 34, '烯烃厂工会': 4, '化学品厂工会': 8, '合成树脂厂': 4, '生产运行保障中心': 1, '高科公司工会': 3, '有机化工厂工会': 3, '机关工会': 4}\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import openpyxl\n", @@ -392,16 +327,9 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": null, "id": "7085bf6f-7465-44fb-bddb-38130fbe5618", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-17T12:58:45.236098Z", - "iopub.status.busy": "2023-04-17T12:58:45.235274Z", - "iopub.status.idle": "2023-04-17T12:58:46.270936Z", - "shell.execute_reply": "2023-04-17T12:58:46.270191Z", - "shell.execute_reply.started": "2023-04-17T12:58:45.236059Z" - }, "tags": [] }, "outputs": [], @@ -449,16 +377,9 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "id": "eddf7dab-b28d-402a-aeaf-27c120048ecb", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-16T08:44:33.173111Z", - "iopub.status.busy": "2023-05-16T08:44:33.172278Z", - "iopub.status.idle": "2023-05-16T08:44:33.373625Z", - "shell.execute_reply": "2023-05-16T08:44:33.372928Z", - "shell.execute_reply.started": "2023-05-16T08:44:33.173071Z" - }, "tags": [] }, "outputs": [], @@ -521,15 +442,15 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 73, "id": "641863ef-324f-4c33-a0a9-699031afb6f1", "metadata": { "execution": { - "iopub.execute_input": "2023-05-17T01:34:11.475000Z", - "iopub.status.busy": "2023-05-17T01:34:11.474266Z", - "iopub.status.idle": "2023-05-17T01:34:11.673023Z", - "shell.execute_reply": "2023-05-17T01:34:11.672256Z", - "shell.execute_reply.started": "2023-05-17T01:34:11.474959Z" + "iopub.execute_input": "2023-05-26T14:47:09.071920Z", + "iopub.status.busy": "2023-05-26T14:47:09.071521Z", + "iopub.status.idle": "2023-05-26T14:47:09.257365Z", + "shell.execute_reply": "2023-05-26T14:47:09.256643Z", + "shell.execute_reply.started": "2023-05-26T14:47:09.071892Z" }, "tags": [] }, @@ -538,7 +459,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "[['4025', '马珺', '教育培训中心工会', '身高,体重,选择反应时'], ['7790', '吴志鹏', '生产运行保障中心', '身高,体重,握力'], ['3377', '安明海', '检验计量中心工会', '俯卧撑,纵跳'], ['3520', '于海军', '检验计量中心工会', '握力'], ['3125', '李志斌', '化学品厂工会', '身高,体重,握力'], ['5690', '胡勇', '热电厂工会', '身高,体重'], ['4551', '韩立江', '炼油厂工会', '身高,体重'], ['8150', '王重荃', '高科公司工会', '台阶指数']]\n" + "[]\n" ] } ], @@ -548,7 +469,7 @@ "\n", "items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", "title = ['编号','姓名','性别','单位','车间','班组','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", - "filename = 'data/result_燕山石化-all.json'\n", + "filename = 'data/result_燕山石化.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl)\n", "\n", @@ -573,7 +494,7 @@ " list2.append(xm)\n", " list1.append(list2)\n", "print(list1)\n", - "filename = 'data/燕山石化测试项目不足人员(截止5月16日).xlsx'\n", + "filename = 'data/燕山石化测试项目不足人员.xlsx'\n", "wb = openpyxl.Workbook()\n", "sheet = wb.active\n", "#sheet.append(title)\n", @@ -593,28 +514,12 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "b735248a-c1b0-4e90-8df4-37cd7625cb1a", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-18T12:37:18.648377Z", - "iopub.status.busy": "2023-05-18T12:37:18.647570Z", - "iopub.status.idle": "2023-05-18T12:37:19.435077Z", - "shell.execute_reply": "2023-05-18T12:37:19.434303Z", - "shell.execute_reply.started": "2023-05-18T12:37:18.648344Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7734\n", - "7734\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import time\n", @@ -634,7 +539,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "\n", - "filename = 'data/places_result_20230518.csv'\n", + "filename = 'data/places_result_20230526.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -656,7 +561,7 @@ " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", "print(len(re_ta))\n", "\n", - "filename = 'data/result_燕山石化-all.json'\n", + "filename = 'data/result_燕山石化.json'\n", "with open(filename,'w') as fl:\n", " json.dump(re_ta, fl, ensure_ascii=False) \n", "print(len(re_ta))" @@ -672,34 +577,19 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "id": "6d10738f-8da8-4f18-970b-e67433a06661", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-18T12:55:07.441554Z", - "iopub.status.busy": "2023-05-18T12:55:07.440708Z", - "iopub.status.idle": "2023-05-18T12:55:07.819534Z", - "shell.execute_reply": "2023-05-18T12:55:07.818801Z", - "shell.execute_reply.started": "2023-05-18T12:55:07.441512Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "7734\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import time\n", "import csv\n", "\n", "person = set()\n", - "filename = 'data/places_result_20230518.csv'\n", + "filename = 'data/places_result_20230526.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -729,16 +619,9 @@ }, { "cell_type": "code", - "execution_count": 132, + "execution_count": null, "id": "0dd5da15-92e0-45c2-b9e9-11417210974e", "metadata": { - "execution": { - "iopub.execute_input": "2023-04-27T07:22:33.663659Z", - "iopub.status.busy": "2023-04-27T07:22:33.662808Z", - "iopub.status.idle": "2023-04-27T07:22:35.472369Z", - "shell.execute_reply": "2023-04-27T07:22:35.471662Z", - "shell.execute_reply.started": "2023-04-27T07:22:33.663618Z" - }, "tags": [] }, "outputs": [], @@ -787,31 +670,12 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "id": "5df8eb8f-3594-40be-a491-b4d750bbd554", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-16T08:44:02.431464Z", - "iopub.status.busy": "2023-05-16T08:44:02.430604Z", - "iopub.status.idle": "2023-05-16T08:44:02.587531Z", - "shell.execute_reply": "2023-05-16T08:44:02.586608Z", - "shell.execute_reply.started": "2023-05-16T08:44:02.431421Z" - }, "tags": [] }, - "outputs": [ - { - "ename": "KeyError", - "evalue": "'7160'", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[36], line 27\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m sheet\u001b[38;5;241m.\u001b[39mcell(n,\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mvalue \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 26\u001b[0m code \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(sheet\u001b[38;5;241m.\u001b[39mcell(n, \u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39mvalue)\n\u001b[0;32m---> 27\u001b[0m name \u001b[38;5;241m=\u001b[39m \u001b[43mdict1\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;28;43mstr\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mcode\u001b[49m\u001b[43m)\u001b[49m\u001b[43m]\u001b[49m[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mname\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 28\u001b[0m unit \u001b[38;5;241m=\u001b[39m dict1[\u001b[38;5;28mstr\u001b[39m(code)][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m工作单位\u001b[39m\u001b[38;5;124m'\u001b[39m]\n\u001b[1;32m 29\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mstr\u001b[39m(code) \u001b[38;5;129;01min\u001b[39;00m dict2\u001b[38;5;241m.\u001b[39mkeys():\n", - "\u001b[0;31mKeyError\u001b[0m: '7160'" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import time\n", @@ -866,27 +730,12 @@ }, { "cell_type": "code", - "execution_count": 193, + "execution_count": null, "id": "48a0b2b8-c069-4d2d-9813-d65474749000", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-06T12:38:29.815090Z", - "iopub.status.busy": "2023-05-06T12:38:29.814674Z", - "iopub.status.idle": "2023-05-06T12:38:29.943125Z", - "shell.execute_reply": "2023-05-06T12:38:29.942309Z", - "shell.execute_reply.started": "2023-05-06T12:38:29.815063Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[['机关工会', 446, 365], ['储运厂工会', 997, 780], ['高科公司工会', 311, 292], ['合成树脂厂', 464, 317], ['合成橡胶厂工会', 770, 310], ['化学品厂工会', 378, 296], ['检验计量中心工会', 635, 297], ['教育培训中心工会', 73, 72], ['炼油厂工会', 1043, 640], ['热电厂工会', 710, 121], ['物装中心工会', 182, 182], ['烯烃厂工会', 433, 287], ['消防中心工会', 221, 214], ['行政事务中心(离退中心)工会', 675, 503], ['有机化工厂工会', 454, 435], ['生产运行保障中心', 398, 367]]\n" - ] - } - ], + "outputs": [], "source": [ "import json\n", "import openpyxl\n", @@ -929,28 +778,12 @@ }, { "cell_type": "code", - "execution_count": 217, + "execution_count": null, "id": "c294db76-adc4-41bf-9ee6-811dde1905e8", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-09T02:59:10.544101Z", - "iopub.status.busy": "2023-05-09T02:59:10.543244Z", - "iopub.status.idle": "2023-05-09T02:59:10.550360Z", - "shell.execute_reply": "2023-05-09T02:59:10.549157Z", - "shell.execute_reply.started": "2023-05-09T02:59:10.544059Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "bs b'\\xc2\\xed\\xc1\\xa2\\xd1\\xc7'\n", - "decode-bs: 马立亚\n" - ] - } - ], + "outputs": [], "source": [ "#C2EDC1A2D1C7\n", "gbs = 'C2EDC1A2D1C7'\n", @@ -962,28 +795,12 @@ }, { "cell_type": "code", - "execution_count": 219, + "execution_count": null, "id": "9924d06a-8753-4856-9ccc-f3d5f8956bb2", "metadata": { - "execution": { - "iopub.execute_input": "2023-05-09T03:06:42.922674Z", - "iopub.status.busy": "2023-05-09T03:06:42.921808Z", - "iopub.status.idle": "2023-05-09T03:06:42.929473Z", - "shell.execute_reply": "2023-05-09T03:06:42.928345Z", - "shell.execute_reply.started": "2023-05-09T03:06:42.922633Z" - }, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "gbcode: b'\\xc2\\xed\\xc1\\xa2\\xd1\\xc7'\n", - "gbs: c2edc1a2d1c7\n" - ] - } - ], + "outputs": [], "source": [ "s = '马立亚'\n", "gbcode = s.encode('gb2312') # 先转成 bytes格式\n", @@ -992,10 +809,1294 @@ "print('gbs:', gbs)" ] }, + { + "cell_type": "markdown", + "id": "ce1487ed-2b11-4a3c-a305-5499af4526d1", + "metadata": {}, + "source": [ + "## 数据分析" + ] + }, + { + "cell_type": "markdown", + "id": "08500016-4f33-446c-bc44-28e0a22a591a", + "metadata": {}, + "source": [ + "### 获取清理后数据" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "id": "aab3ed2b-54f1-42de-8e83-cc559827a4b5", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:09.829773Z", + "iopub.status.busy": "2023-05-27T13:07:09.829372Z", + "iopub.status.idle": "2023-05-27T13:07:10.760194Z", + "shell.execute_reply": "2023-05-27T13:07:10.759179Z", + "shell.execute_reply.started": "2023-05-27T13:07:09.829747Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "7734\n", + "['3520', '7790', '3125', '4025', '3231', '5690', '4551']\n", + "7727\n", + "ok\n", + "7727\n" + ] + } + ], + "source": [ + "import json\n", + "import time\n", + "import csv\n", + "\n", + "filename = '../item.json'\n", + "item = {}\n", + "unit = {}\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for k,v in dict1.items():\n", + " item[k] = v\n", + "filename = 'data/燕山石化人员名单.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "\n", + "re_ta = {}\n", + "list1 = []\n", + "#print(\"\\n运动项目信息:\")\n", + "filename = 'data/places_result_20230527.csv'\n", + "with open(filename,'r',newline='') as csv_file:\n", + " fl = csv.reader(csv_file,delimiter=',')\n", + " header = next(fl) \n", + " for line in fl:\n", + " #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n", + " list1.append(line)\n", + "#print(list1)\n", + "for result in list1:\n", + " user = str(result[2])\n", + " if user in dict1.keys(): \n", + " m_item = str(result[3]) \n", + " re_ta.setdefault(user,{}) \n", + " re_ta[user]['name'] = dict1[user]['name']\n", + " re_ta[user]['unit'] = dict1[user]['工作单位']\n", + " re_ta[user]['sex'] = dict1[user]['sex']\n", + " re_ta[user]['birth'] = dict1[user]['birth'].replace('-','/')\n", + " item_name = item[m_item]['name']\n", + " re_ta[user].setdefault(item_name,{}) \n", + " score = int(result[4])/item[m_item]['divisor'] \n", + " re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n", + " re_ta[user][item_name]['得分'] =result[5]\n", + "filename = 'data/result_燕山石化1.json'\n", + "print(len(re_ta))\n", + "liwai = []\n", + "for k, v in re_ta.items():\n", + " if (len(v)<8 and '身高' in v and '体重' in v) or (len(v)<7 and '身高' not in v and '体重' not in v) :\n", + " liwai.append(k)\n", + "print(liwai)\n", + "for k in liwai:\n", + " del re_ta[k]\n", + "print(len(re_ta))\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(re_ta, fl) \n", + "print('ok')\n", + "print(len(re_ta))" + ] + }, + { + "cell_type": "markdown", + "id": "a3ce7905-c849-48dc-996c-2eeee59e75aa", + "metadata": {}, + "source": [ + "### 计算人员年龄" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "9851d728-8c85-48fd-b7d6-d0104318e89d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:15.219600Z", + "iopub.status.busy": "2023-05-27T13:07:15.219207Z", + "iopub.status.idle": "2023-05-27T13:07:15.684092Z", + "shell.execute_reply": "2023-05-27T13:07:15.683071Z", + "shell.execute_reply.started": "2023-05-27T13:07:15.219573Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "import datetime\n", + "\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "for k, v in dict1.items(): \n", + " birth = v['birth'].split()[0].split('/') \n", + " nian = int(birth[0].strip())\n", + " yue = int(birth[1].strip())\n", + " ri = int(birth[2].strip())\n", + " #print(k,nian,yue,ri)\n", + " days = (datetime.date(2023, 5, 18)-datetime.date(nian,yue,ri)).days\n", + " v['age'] = round(days/365)\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok') " + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "id": "e0f26f0a-6374-4903-a6c9-99cf25e5db2a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T12:56:45.270021Z", + "iopub.status.busy": "2023-05-27T12:56:45.269580Z", + "iopub.status.idle": "2023-05-27T12:56:45.401202Z", + "shell.execute_reply": "2023-05-27T12:56:45.400687Z", + "shell.execute_reply.started": "2023-05-27T12:56:45.269990Z" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl)\n", + "list1 = []\n", + "for k,v in dict1.items():\n", + " if v['age'] < 19:\n", + " print(k,v['name'],v['age'] )\n" + ] + }, + { + "cell_type": "markdown", + "id": "34ae5549-b31c-481e-986a-e1ad8bb1ccc5", + "metadata": {}, + "source": [ + "### 汇总人员信息及成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 108, + "id": "d171e87d-9709-4de8-8261-e1eb4343e002", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:18.957951Z", + "iopub.status.busy": "2023-05-27T13:07:18.957558Z", + "iopub.status.idle": "2023-05-27T13:07:19.475930Z", + "shell.execute_reply": "2023-05-27T13:07:19.475170Z", + "shell.execute_reply.started": "2023-05-27T13:07:18.957923Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "\n", + "items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for k,v in dict1.items():\n", + " score = 0\n", + " i = 0 \n", + " for k1,v1 in v.items(): \n", + " if k1 in items:\n", + " score = score + int(v1['得分'])\n", + " i+=1\n", + " dict1[k]['score'] = round(score/i,2) \n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "8ccea925-2396-4dd9-8cc7-731f11aa3529", + "metadata": {}, + "source": [ + "### 计算测试等级" + ] + }, + { + "cell_type": "code", + "execution_count": 109, + "id": "864da63f-bc6a-4246-81ec-e626680cf300", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:24.343430Z", + "iopub.status.busy": "2023-05-27T13:07:24.342578Z", + "iopub.status.idle": "2023-05-27T13:07:24.834062Z", + "shell.execute_reply": "2023-05-27T13:07:24.833272Z", + "shell.execute_reply.started": "2023-05-27T13:07:24.343389Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:3667人,男性:3136人,女性:531人\n", + "256~332分人数:3117人,男性:2033人,女性:1084人\n", + "333~367分人数:745人,男性:383人,女性:362人\n", + "368~500分人数:198人,男性:74人,女性:124人\n", + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "\n", + "for k1, v1 in dict2.items():\n", + " di = v1[0]\n", + " gao = v1[1]\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if int(v['score']*100) in range(di,gao+1):\n", + " dict1[k]['level'] = k1\n", + " i+=1\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " else:\n", + " f = f+1\n", + " print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "c58f8632-7588-4f4d-8117-91f1a7b11688", + "metadata": {}, + "source": [ + "### 根据年龄汇总人员信息及成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "id": "b605b817-da5f-407f-916b-ce4750727335", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:41.685574Z", + "iopub.status.busy": "2023-05-27T13:07:41.685226Z", + "iopub.status.idle": "2023-05-27T13:07:41.804179Z", + "shell.execute_reply": "2023-05-27T13:07:41.803229Z", + "shell.execute_reply.started": "2023-05-27T13:07:41.685551Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.4分,人数:429人,男性:312人\n", + "25~29岁平均成绩:2.58分,人数:400人,男性:245人\n", + "30~34岁平均成绩:2.6分,人数:309人,男性:210人\n", + "35~39岁平均成绩:2.7分,人数:553人,男性:317人\n", + "40~44岁平均成绩:2.57分,人数:1339人,男性:844人\n", + "45~49岁平均成绩:2.55分,人数:1687人,男性:1071人\n", + "50~54岁平均成绩:2.53分,人数:1920人,男性:1559人\n", + "55~69岁平均成绩:2.43分,人数:1090人,男性:1068人\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " i = 1\n", + " score = 0\n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1):\n", + " score = score+v['score']\n", + " i+=1\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " \n", + " print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人,男性:{m}人')" + ] + }, + { + "cell_type": "markdown", + "id": "1ea7f10f-7c80-4888-a00e-69dbaeceb100", + "metadata": {}, + "source": [ + "#### 根据年龄汇总人员信息及成绩(男)" + ] + }, + { + "cell_type": "code", + "execution_count": 111, + "id": "96506507-439f-42b5-93f7-bcba8930dae9", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:07:48.465152Z", + "iopub.status.busy": "2023-05-27T13:07:48.464314Z", + "iopub.status.idle": "2023-05-27T13:07:48.630296Z", + "shell.execute_reply": "2023-05-27T13:07:48.629582Z", + "shell.execute_reply.started": "2023-05-27T13:07:48.465113Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.31分,人数:312人\n", + "25~29岁平均成绩:2.44分,人数:245人\n", + "30~34岁平均成绩:2.43分,人数:210人\n", + "35~39岁平均成绩:2.5分,人数:317人\n", + "40~44岁平均成绩:2.43分,人数:844人\n", + "45~49岁平均成绩:2.38分,人数:1071人\n", + "50~54岁平均成绩:2.44分,人数:1559人\n", + "55~80岁平均成绩:2.41分,人数:1068人\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " i = 1\n", + " score = 0\n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1) and v['sex'] == '男':\n", + " score = score+v['score']\n", + " i+=1\n", + " \n", + " \n", + " print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')" + ] + }, + { + "cell_type": "markdown", + "id": "bd906618-8b50-450d-bb32-a2554da91b9a", + "metadata": {}, + "source": [ + "#### 根据年龄汇总人员信息及成绩(女)" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "id": "10cc353b-32cb-45eb-9362-da22b170c301", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:02.434443Z", + "iopub.status.busy": "2023-05-27T13:08:02.434037Z", + "iopub.status.idle": "2023-05-27T13:08:02.593896Z", + "shell.execute_reply": "2023-05-27T13:08:02.593181Z", + "shell.execute_reply.started": "2023-05-27T13:08:02.434415Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.63分,人数:117人\n", + "25~29岁平均成绩:2.8分,人数:155人\n", + "30~34岁平均成绩:2.95分,人数:99人\n", + "35~39岁平均成绩:2.95分,人数:236人\n", + "40~44岁平均成绩:2.79分,人数:495人\n", + "45~49岁平均成绩:2.84分,人数:616人\n", + "50~54岁平均成绩:2.94分,人数:361人\n", + "55~80岁平均成绩:2.91分,人数:22人\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "filename = 'data/result_燕山石化.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " i = 1\n", + " score = 0\n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1) and v['sex'] == '女':\n", + " score = score+v['score']\n", + " i+=1\n", + " \n", + " \n", + " print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')" + ] + }, + { + "cell_type": "markdown", + "id": "f0c57ed7-4ab6-4415-aac4-f55ca117743e", + "metadata": {}, + "source": [ + "### 计算平均成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 113, + "id": "532b4d97-df50-4fd9-9e85-1181afcd366e", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:06.957835Z", + "iopub.status.busy": "2023-05-27T13:08:06.957012Z", + "iopub.status.idle": "2023-05-27T13:08:07.096914Z", + "shell.execute_reply": "2023-05-27T13:08:07.096024Z", + "shell.execute_reply.started": "2023-05-27T13:08:06.957795Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "平均成绩:2.4206分,男性:5626人\n", + "平均成绩:2.859分,女性:2101人\n", + "平均成绩:2.5398分,总体:7727人\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "#filename = 'data/result_石家庄.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "i = 1\n", + "m = 0\n", + "f = 0\n", + "score = 0\n", + "t_score = 0\n", + "for k,v in dict1.items():\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " score = score+v['score']\n", + "print(f'平均成绩:{round(score/m,4)}分,男性:{m}人')\n", + "t_score = t_score + score\n", + "score = 0\n", + "for k,v in dict1.items():\n", + " if v['sex'] == '女':\n", + " f = f +1\n", + " score = score+v['score']\n", + "print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')\n", + "t_score = t_score + score\n", + "print(f'平均成绩:{round(t_score/7727,4)}分,总体:7727人')" + ] + }, + { + "cell_type": "markdown", + "id": "b18769df-ccfb-4013-82ea-51e6a3e24565", + "metadata": {}, + "source": [ + "### 计算测试等级" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "id": "4377cf1d-83f0-4e6b-819f-f274915886b9", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:27.764353Z", + "iopub.status.busy": "2023-05-27T13:08:27.763918Z", + "iopub.status.idle": "2023-05-27T13:08:28.264684Z", + "shell.execute_reply": "2023-05-27T13:08:28.263691Z", + "shell.execute_reply.started": "2023-05-27T13:08:27.764325Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:3667人,男性:3136人,女性:531人\n", + "256~332分人数:3117人,男性:2033人,女性:1084人\n", + "333~367分人数:745人,男性:383人,女性:362人\n", + "368~500分人数:198人,男性:74人,女性:124人\n", + "ok\n" + ] + } + ], + "source": [ + "import json\n", + "\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "\n", + "for k1, v1 in dict2.items():\n", + " di = v1[0]\n", + " gao = v1[1]\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if int(v['score']*100) in range(di,gao+1):\n", + " dict1[k]['level'] = k1\n", + " i+=1\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " else:\n", + " f = f+1\n", + " print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n", + "#filename = 'data/result_石家庄.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "ee6b0500-bf94-458f-8d1c-0e75e8dcc1f5", + "metadata": {}, + "source": [ + "### 计算各年龄段测试等级(女)" + ] + }, + { + "cell_type": "code", + "execution_count": 115, + "id": "4fafdc11-c93b-4a8d-854e-61748713d0f8", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:31.927585Z", + "iopub.status.busy": "2023-05-27T13:08:31.927169Z", + "iopub.status.idle": "2023-05-27T13:08:32.089666Z", + "shell.execute_reply": "2023-05-27T13:08:32.088681Z", + "shell.execute_reply.started": "2023-05-27T13:08:31.927557Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20-24 {'不合格': 44, '合格': 65, '良好': 5, '优秀': 3}\n", + "25-29 {'不合格': 43, '良好': 35, '合格': 74, '优秀': 3}\n", + "30-34 {'不合格': 17, '合格': 58, '良好': 19, '优秀': 5}\n", + "35-39 {'不合格': 44, '合格': 128, '良好': 52, '优秀': 12}\n", + "40-44 {'良好': 72, '不合格': 146, '合格': 241, '优秀': 36}\n", + "45-49 {'不合格': 167, '合格': 316, '优秀': 38, '良好': 95}\n", + "50-54 {'不合格': 65, '合格': 193, '良好': 77, '优秀': 26}\n", + "55-80 {'合格': 9, '不合格': 5, '优秀': 1, '良好': 7}\n" + ] + } + ], + "source": [ + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "dict3 = {}\n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " age = f'{di}-{gao}'\n", + " dict3.setdefault(age,{})\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1): \n", + " dict3[age].setdefault(v['level'],0)\n", + " if v['sex'] == '女':\n", + " dict3[age][v['level']] = dict3[age][v['level']]+1\n", + " \n", + "for k, v in dict3.items():\n", + " print(k,v)" + ] + }, + { + "cell_type": "markdown", + "id": "bebb0307-62e7-458c-a78a-90c593595a67", + "metadata": {}, + "source": [ + "### 计算各年龄段测试等级(男)" + ] + }, + { + "cell_type": "code", + "execution_count": 116, + "id": "cae4d5b6-20ef-4a24-91ea-59ddc691349a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:35.357895Z", + "iopub.status.busy": "2023-05-27T13:08:35.357070Z", + "iopub.status.idle": "2023-05-27T13:08:35.520889Z", + "shell.execute_reply": "2023-05-27T13:08:35.520000Z", + "shell.execute_reply.started": "2023-05-27T13:08:35.357854Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20-24 {'不合格': 204, '合格': 96, '良好': 11, '优秀': 1}\n", + "25-29 {'不合格': 140, '良好': 19, '合格': 84, '优秀': 2}\n", + "30-34 {'不合格': 111, '合格': 81, '良好': 15, '优秀': 3}\n", + "35-39 {'不合格': 161, '合格': 124, '良好': 27, '优秀': 5}\n", + "40-44 {'良好': 63, '不合格': 462, '合格': 302, '优秀': 17}\n", + "45-49 {'不合格': 606, '合格': 389, '优秀': 11, '良好': 65}\n", + "50-54 {'不合格': 853, '合格': 567, '良好': 117, '优秀': 22}\n", + "55-80 {'合格': 390, '不合格': 599, '优秀': 13, '良好': 66}\n" + ] + } + ], + "source": [ + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "dict3 = {}\n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " age = f'{di}-{gao}'\n", + " dict3.setdefault(age,{})\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1): \n", + " dict3[age].setdefault(v['level'],0)\n", + " if v['sex'] == '男':\n", + " dict3[age][v['level']] = dict3[age][v['level']]+1\n", + " \n", + "for k, v in dict3.items():\n", + " print(k,v)" + ] + }, + { + "cell_type": "markdown", + "id": "f7ce0701-4f39-46fd-b284-2274abf7d329", + "metadata": {}, + "source": [ + "### 按照部门计算平均成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 117, + "id": "9d5660b9-2046-4319-b2c2-29ba5ddf818f", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:41.550284Z", + "iopub.status.busy": "2023-05-27T13:08:41.549870Z", + "iopub.status.idle": "2023-05-27T13:08:41.722994Z", + "shell.execute_reply": "2023-05-27T13:08:41.722259Z", + "shell.execute_reply.started": "2023-05-27T13:08:41.550257Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "热电厂工会 2.41 681\n", + "炼油厂工会 2.48 1006\n", + "有机化工厂工会 2.57 446\n", + "储运厂工会 2.37 983\n", + "合成橡胶厂工会 2.46 713\n", + "检验计量中心工会 2.62 632\n", + "烯烃厂工会 2.59 410\n", + "化学品厂工会 2.4 368\n", + "合成树脂厂 2.46 443\n", + "生产运行保障中心 2.56 371\n", + "高科公司工会 2.69 304\n", + "机关工会 2.84 378\n", + "行政事务中心(离退中心)工会 2.76 524\n", + "教育培训中心工会 2.73 72\n", + "物装中心工会 2.67 182\n", + "消防中心工会 2.81 214\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "depart = []\n", + "for k, v in dict1.items():\n", + " if v['unit'] not in depart:\n", + " depart.append(v['unit'])\n", + "\n", + "for item in depart:\n", + " score = 0\n", + " n = 0\n", + " for k, v in dict1.items():\n", + " if item == v['unit']:\n", + " score = score + v['score']\n", + " n = n +1 \n", + " print(item,round(score/n,2),n)\n", + " " + ] + }, + { + "cell_type": "markdown", + "id": "d9122bbd-5767-4fe5-9bb2-c4d73a27a433", + "metadata": {}, + "source": [ + "### 计算各项目成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 118, + "id": "38d9f91d-18de-4df1-8179-03579008c2d0", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:45.314635Z", + "iopub.status.busy": "2023-05-27T13:08:45.314235Z", + "iopub.status.idle": "2023-05-27T13:08:45.484153Z", + "shell.execute_reply": "2023-05-27T13:08:45.483219Z", + "shell.execute_reply.started": "2023-05-27T13:08:45.314607Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "体重 3.41 7724\n", + "肺活量 2.96 7651\n", + "握力 2.36 7677\n", + "坐位体前屈 2.78 6752\n", + "纵跳 1.89 7302\n", + "俯卧撑 1.99 4557\n", + "一分钟仰卧起坐 3.81 1680\n", + "单脚站立 1.7 7561\n", + "选择反应时 2.76 7579\n", + "台阶指数 2.77 5257\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "for item in items:\n", + " score = 0\n", + " n = 0\n", + " for k, v in dict1.items():\n", + " if item in v.keys():\n", + " n = n + 1\n", + " score =score + int(v[item]['得分'])\n", + " print(item,round(score/n,2),n)" + ] + }, + { + "cell_type": "markdown", + "id": "bce1d676-d5f5-47b0-8a51-a1bb74a66674", + "metadata": {}, + "source": [ + "### 生成倒班人员信息表" + ] + }, + { + "cell_type": "code", + "execution_count": 119, + "id": "0bf8400c-060e-420e-ba66-04fb67bfc09a", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:08:51.679613Z", + "iopub.status.busy": "2023-05-27T13:08:51.678996Z", + "iopub.status.idle": "2023-05-27T13:08:54.061451Z", + "shell.execute_reply": "2023-05-27T13:08:54.060702Z", + "shell.execute_reply.started": "2023-05-27T13:08:51.679572Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3478\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "\n", + "wb = openpyxl.load_workbook('data/燕山石化人员情况表.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "daoban = {}\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "\n", + "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,1).value is not None:\n", + " code = int(sheet.cell(n, 1).value)\n", + " if sheet.cell(n, 12).value == '倒班' and str(code) in dict1.keys():\n", + " daoban[str(code)] = dict1[str(code)]\n", + "\n", + "filename = 'data/daoban_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(daoban, fl, ensure_ascii=False) \n", + "print(len(daoban)) " + ] + }, + { + "cell_type": "markdown", + "id": "8b6e02ac-0ce7-4cd3-8da9-025d93a24a53", + "metadata": {}, + "source": [ + "### 倒班人员构成" + ] + }, + { + "cell_type": "code", + "execution_count": 120, + "id": "daa09874-e7a1-4aaa-b648-023e8358adfb", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:09:05.580283Z", + "iopub.status.busy": "2023-05-27T13:09:05.579869Z", + "iopub.status.idle": "2023-05-27T13:09:05.825237Z", + "shell.execute_reply": "2023-05-27T13:09:05.824360Z", + "shell.execute_reply.started": "2023-05-27T13:09:05.580256Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:1933人,男性:1675人,女性:258人\n", + "256~332分人数:1263人,男性:906人,女性:357人\n", + "333~367分人数:228人,男性:140人,女性:88人\n", + "368~500分人数:54人,男性:30人,女性:24人\n", + "ok\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "\n", + "for k1, v1 in dict2.items():\n", + " di = v1[0]\n", + " gao = v1[1]\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if int(v['score']*100) in range(di,gao+1):\n", + " dict1[k]['level'] = k1\n", + " i+=1\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " else:\n", + " f = f+1\n", + " print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n", + "filename = 'data/daoban_燕山石化.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "8ad58c29-eb07-48d9-8d62-c5af158c02bf", + "metadata": {}, + "source": [ + "### 倒班人员年龄段成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 121, + "id": "43d4e63d-a615-4ac0-b075-c938dc346e98", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:09:44.193852Z", + "iopub.status.busy": "2023-05-27T13:09:44.192991Z", + "iopub.status.idle": "2023-05-27T13:09:44.545582Z", + "shell.execute_reply": "2023-05-27T13:09:44.544856Z", + "shell.execute_reply.started": "2023-05-27T13:09:44.193810Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.31分,人数:184人\n", + "25~29岁平均成绩:2.41分,人数:96人\n", + "30~34岁平均成绩:2.33分,人数:99人\n", + "35~39岁平均成绩:2.36分,人数:113人\n", + "40~44岁平均成绩:2.35分,人数:527人\n", + "45~49岁平均成绩:2.32分,人数:616人\n", + "50~54岁平均成绩:2.35分,人数:739人\n", + "55~80岁平均成绩:2.32分,人数:377人\n" + ] + } + ], + "source": [ + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " i = 1\n", + " score = 0\n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1) and v['sex'] == '男':\n", + " score = score+v['score']\n", + " i+=1\n", + " \n", + " \n", + " print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "id": "69d07666-1a7d-42a0-85df-e88f956b9444", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:09:52.831237Z", + "iopub.status.busy": "2023-05-27T13:09:52.830821Z", + "iopub.status.idle": "2023-05-27T13:09:52.930980Z", + "shell.execute_reply": "2023-05-27T13:09:52.930197Z", + "shell.execute_reply.started": "2023-05-27T13:09:52.831209Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "20~24岁平均成绩:2.57分,人数:69人\n", + "25~29岁平均成绩:2.67分,人数:32人\n", + "30~34岁平均成绩:2.73分,人数:18人\n", + "35~39岁平均成绩:2.62分,人数:43人\n", + "40~44岁平均成绩:2.63分,人数:228人\n", + "45~49岁平均成绩:2.7分,人数:295人\n", + "50~54岁平均成绩:2.71分,人数:42人\n", + "55~80岁平均成绩:0.0分,人数:0人\n" + ] + } + ], + "source": [ + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "for item in nld:\n", + " di = item[0]\n", + " gao = item[1]\n", + " i = 1\n", + " score = 0\n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if v['age'] in range(di,gao+1) and v['sex'] == '女':\n", + " score = score+v['score']\n", + " i+=1\n", + " \n", + " \n", + " print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')" + ] + }, + { + "cell_type": "markdown", + "id": "aca6bfe1-b0c3-41b5-a0be-a5c1af071cbf", + "metadata": {}, + "source": [ + "## 倒班人员测试等级" + ] + }, + { + "cell_type": "code", + "execution_count": 123, + "id": "798112d0-63e6-4a4b-9959-dbadf3c4ed54", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:11:29.890108Z", + "iopub.status.busy": "2023-05-27T13:11:29.889257Z", + "iopub.status.idle": "2023-05-27T13:11:30.148770Z", + "shell.execute_reply": "2023-05-27T13:11:30.148046Z", + "shell.execute_reply.started": "2023-05-27T13:11:29.890066Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:1933人,男性:1675人,女性:258人\n", + "256~332分人数:1263人,男性:906人,女性:357人\n", + "333~367分人数:228人,男性:140人,女性:88人\n", + "368~500分人数:54人,男性:30人,女性:24人\n", + "ok\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "dict2 = {}\n", + "dict2['不合格'] = [0,255]\n", + "dict2['合格'] = [256,332]\n", + "dict2['良好'] = [333,367]\n", + "dict2['优秀'] = [368,500]\n", + "\n", + "for k1, v1 in dict2.items():\n", + " di = v1[0]\n", + " gao = v1[1]\n", + " i = 0 \n", + " m = 0\n", + " f = 0\n", + " for k,v in dict1.items():\n", + " if int(v['score']*100) in range(di,gao+1):\n", + " dict1[k]['level'] = k1\n", + " i+=1\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " else:\n", + " f = f+1\n", + " print(f'{di}~{gao}分人数:{i}人,男性:{m}人,女性:{f}人')\n", + "#filename = 'data/result_石家庄.json'\n", + "with open(filename,'w') as fl:\n", + " json.dump(dict1, fl) \n", + "print('ok')" + ] + }, + { + "cell_type": "markdown", + "id": "5afed106-e77b-453b-bcdf-29c00665a4bd", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:57:01.082474Z", + "iopub.status.busy": "2023-05-27T13:57:01.082047Z", + "iopub.status.idle": "2023-05-27T13:57:01.086797Z", + "shell.execute_reply": "2023-05-27T13:57:01.085545Z", + "shell.execute_reply.started": "2023-05-27T13:57:01.082445Z" + }, + "tags": [] + }, + "source": [ + "### 倒班人员平均成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 125, + "id": "e9444e38-450c-4e70-a98e-aa312d83d9c4", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T13:58:22.704523Z", + "iopub.status.busy": "2023-05-27T13:58:22.703677Z", + "iopub.status.idle": "2023-05-27T13:58:22.796742Z", + "shell.execute_reply": "2023-05-27T13:58:22.795740Z", + "shell.execute_reply.started": "2023-05-27T13:58:22.704483Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "平均成绩:2.3453分,男性:2751人\n", + "平均成绩:2.6869分,女性:727人\n", + "平均成绩:2.4167分,总体:3478人\n" + ] + } + ], + "source": [ + "nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,80]]\n", + "#filename = 'data/result_石家庄.json'\n", + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "i = 1\n", + "m = 0\n", + "f = 0\n", + "score = 0\n", + "t_score = 0\n", + "for k,v in dict1.items():\n", + " if v['sex'] == '男':\n", + " m = m +1\n", + " score = score+v['score']\n", + "print(f'平均成绩:{round(score/m,4)}分,男性:{m}人')\n", + "t_score = t_score + score\n", + "score = 0\n", + "for k,v in dict1.items():\n", + " if v['sex'] == '女':\n", + " f = f +1\n", + " score = score+v['score']\n", + "print(f'平均成绩:{round(score/f,4)}分,女性:{f}人')\n", + "t_score = t_score + score\n", + "print(f'平均成绩:{round(t_score/(m+f),4)}分,总体:{m+f}人')" + ] + }, + { + "cell_type": "markdown", + "id": "8e52fd0b-c4db-4b88-b88e-7edf37714b6e", + "metadata": {}, + "source": [ + "### 计算倒班员工各项目成绩" + ] + }, + { + "cell_type": "code", + "execution_count": 126, + "id": "3248d9c5-bea2-492c-9a7a-ac2c9632b514", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-27T14:58:29.579314Z", + "iopub.status.busy": "2023-05-27T14:58:29.578870Z", + "iopub.status.idle": "2023-05-27T14:58:29.689623Z", + "shell.execute_reply": "2023-05-27T14:58:29.688913Z", + "shell.execute_reply.started": "2023-05-27T14:58:29.579287Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "体重 3.29 3478\n", + "肺活量 2.8 3438\n", + "握力 2.34 3449\n", + "坐位体前屈 2.74 2993\n", + "纵跳 1.7 3288\n", + "俯卧撑 1.94 2198\n", + "一分钟仰卧起坐 3.65 535\n", + "单脚站立 1.44 3390\n", + "选择反应时 2.65 3418\n", + "台阶指数 2.82 2179\n" + ] + } + ], + "source": [ + "with open(filename,'r') as fl:\n", + " dict1 = json.load(fl) \n", + "items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n", + "for item in items:\n", + " score = 0\n", + " n = 0\n", + " for k, v in dict1.items():\n", + " if item in v.keys():\n", + " n = n + 1\n", + " score =score + int(v[item]['得分'])\n", + " print(item,round(score/n,2),n)" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "930f3a2c-e39b-4d2c-916e-c99588e90274", + "id": "12f5e54e-635d-450f-8a4f-54de18f3519d", "metadata": {}, "outputs": [], "source": [] diff --git a/体测单位/石家庄石化.ipynb b/体测单位/石家庄石化.ipynb index feb7603..650795b 100644 --- a/体测单位/石家庄石化.ipynb +++ b/体测单位/石家庄石化.ipynb @@ -712,12 +712,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "id": "69b5f5e5-04e4-4509-8518-b7fc54cd4e45", "metadata": { + "execution": { + "iopub.execute_input": "2023-05-26T13:50:58.194003Z", + "iopub.status.busy": "2023-05-26T13:50:58.193208Z", + "iopub.status.idle": "2023-05-26T13:50:58.371452Z", + "shell.execute_reply": "2023-05-26T13:50:58.370543Z", + "shell.execute_reply.started": "2023-05-26T13:50:58.193961Z" + }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0~255分人数:779人,男性:678人,女性:101人\n", + "256~332分人数:1009人,男性:786人,女性:223人\n", + "333~367分人数:316人,男性:189人,女性:127人\n", + "368~500分人数:129人,男性:57人,女性:72人\n", + "ok\n" + ] + } + ], "source": [ "import json\n", "\n", diff --git a/体测单位/长炼医院.ipynb b/体测单位/长炼医院.ipynb index 16cfe24..de5c013 100644 --- a/体测单位/长炼医院.ipynb +++ b/体测单位/长炼医院.ipynb @@ -64,23 +64,23 @@ }, { "cell_type": "markdown", - "id": "96d5b4bd-4198-4725-9005-070ac4e4f324", + "id": "31d36f3c-f046-40a9-bf90-ba139fdcce3a", "metadata": {}, "source": [ - "## 每日成绩导入" + "## 新增人员信息" ] }, { "cell_type": "code", - "execution_count": 6, - "id": "4b52477e-926a-44b5-b8a0-20bff98d101d", + "execution_count": 7, + "id": "5cea2f5e-37fc-4857-8455-090a634a1c0a", "metadata": { "execution": { - "iopub.execute_input": "2023-05-15T10:43:30.775840Z", - "iopub.status.busy": "2023-05-15T10:43:30.775025Z", - "iopub.status.idle": "2023-05-15T10:43:30.794406Z", - "shell.execute_reply": "2023-05-15T10:43:30.793511Z", - "shell.execute_reply.started": "2023-05-15T10:43:30.775797Z" + "iopub.execute_input": "2023-05-26T10:04:21.856051Z", + "iopub.status.busy": "2023-05-26T10:04:21.855163Z", + "iopub.status.idle": "2023-05-26T10:04:22.498099Z", + "shell.execute_reply": "2023-05-26T10:04:22.497093Z", + "shell.execute_reply.started": "2023-05-26T10:04:21.856007Z" }, "tags": [] }, @@ -89,8 +89,75 @@ "name": "stdout", "output_type": "stream", "text": [ - "6\n", - "6\n" + "528\n", + "ok\n", + "992\n" + ] + } + ], + "source": [ + "import openpyxl\n", + "import json\n", + "\n", + "\n", + "wb = openpyxl.load_workbook('data/长炼医院新增监测花名册.xlsx')\n", + "sheet = wb.active\n", + "# sheets = wb.sheetnames\n", + "filename = 'data/长炼医院人员名单.json'\n", + "with open(filename,'r') as fl:\n", + " person = json.load(fl) \n", + "print(len(person))\n", + "for n in range(2, sheet.max_row+1):\n", + " if sheet.cell(n,1).value is not None:\n", + " code = int(sheet.cell(n, 4).value)\n", + " person.setdefault(code, {})\n", + " dict1 = {}\n", + " dict1['name'] = sheet.cell(n, 6).value\n", + " if int(sheet.cell(n, 7).value) ==1:\n", + " sex = '男'\n", + " else:\n", + " sex = '女'\n", + " dict1['sex'] = sex\n", + " birth = str(sheet.cell(n, 8).value).split()[0]\n", + " dict1['birth'] = birth\n", + " dict1['unit'] = sheet.cell(n, 3).value\n", + " person[code] = dict1\n", + "filename = 'data/长炼医院人员名单.json'\n", + "with open(filename, 'w') as fl:\n", + " json.dump(person, fl, ensure_ascii=False)\n", + "print('ok')\n", + "print(len(person))" + ] + }, + { + "cell_type": "markdown", + "id": "96d5b4bd-4198-4725-9005-070ac4e4f324", + "metadata": {}, + "source": [ + "## 每日成绩导入" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "4b52477e-926a-44b5-b8a0-20bff98d101d", + "metadata": { + "execution": { + "iopub.execute_input": "2023-05-26T10:04:49.499896Z", + "iopub.status.busy": "2023-05-26T10:04:49.499463Z", + "iopub.status.idle": "2023-05-26T10:04:49.522644Z", + "shell.execute_reply": "2023-05-26T10:04:49.521747Z", + "shell.execute_reply.started": "2023-05-26T10:04:49.499867Z" + }, + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "73\n", + "73\n" ] } ], @@ -112,8 +179,8 @@ "filename = 'data/长炼医院人员名单.json'\n", "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", - "rq = '20230515'\n", - "filename = f'data/places_result_{rq}-clyy.csv'\n", + "rq = '20230526'\n", + "filename = f'data/places_result_{rq}.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -143,15 +210,15 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "id": "033cc564-4aa9-4e88-b38b-ec62a02b1661", "metadata": { "execution": { - "iopub.execute_input": "2023-05-15T10:43:39.337088Z", - "iopub.status.busy": "2023-05-15T10:43:39.336252Z", - "iopub.status.idle": "2023-05-15T10:43:39.361956Z", - "shell.execute_reply": "2023-05-15T10:43:39.360904Z", - "shell.execute_reply.started": "2023-05-15T10:43:39.337046Z" + "iopub.execute_input": "2023-05-26T08:29:09.963390Z", + "iopub.status.busy": "2023-05-26T08:29:09.962538Z", + "iopub.status.idle": "2023-05-26T08:29:10.005878Z", + "shell.execute_reply": "2023-05-26T08:29:10.004986Z", + "shell.execute_reply.started": "2023-05-26T08:29:09.963348Z" }, "tags": [] }, @@ -160,9 +227,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "6\n", - "6\n", - "18\n" + "67\n", + "133 杨诚 已测试!\n", + "76 李克胜 已测试!\n", + "24 李璇 已测试!\n", + "45 乔志刚 已测试!\n", + "136 胡茂山 已测试!\n", + "182 刘立文 已测试!\n", + "163 乐文清 已测试!\n", + "160 李莉 已测试!\n", + "128 王聪 已测试!\n", + "161 王雅琴 已测试!\n", + "72 彭姝 已测试!\n", + "164 高维 已测试!\n", + "134 索怡心 已测试!\n", + "67\n", + "72\n" ] } ], @@ -185,7 +265,7 @@ "with open(filename,'r') as fl:\n", " dict1 = json.load(fl) \n", "#rq = '20230510'\n", - "filename = f'data/places_result_{rq}-clyy.csv'\n", + "filename = f'data/places_result_{rq}.csv'\n", "with open(filename,'r',newline='') as csv_file:\n", " fl = csv.reader(csv_file,delimiter=',')\n", " header = next(fl) \n", @@ -238,15 +318,15 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "id": "2ffa583b-be51-40a8-bb55-de6a89d1a54a", "metadata": { "execution": { - "iopub.execute_input": "2023-05-15T10:43:56.982893Z", - "iopub.status.busy": "2023-05-15T10:43:56.982045Z", - "iopub.status.idle": "2023-05-15T10:43:57.010597Z", - "shell.execute_reply": "2023-05-15T10:43:57.009606Z", - "shell.execute_reply.started": "2023-05-15T10:43:56.982852Z" + "iopub.execute_input": "2023-05-26T10:05:01.804203Z", + "iopub.status.busy": "2023-05-26T10:05:01.803362Z", + "iopub.status.idle": "2023-05-26T10:05:01.863171Z", + "shell.execute_reply": "2023-05-26T10:05:01.862349Z", + "shell.execute_reply.started": "2023-05-26T10:05:01.804161Z" }, "tags": [] }, diff --git a/文件操作.ipynb b/文件操作.ipynb index c2186c7..ab446fb 100644 --- a/文件操作.ipynb +++ b/文件操作.ipynb @@ -364,14 +364,14 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": { "execution": { - "iopub.execute_input": "2023-05-25T04:57:08.561094Z", - "iopub.status.busy": "2023-05-25T04:57:08.560220Z", - "iopub.status.idle": "2023-05-25T04:57:08.638199Z", - "shell.execute_reply": "2023-05-25T04:57:08.637153Z", - "shell.execute_reply.started": "2023-05-25T04:57:08.561054Z" + "iopub.execute_input": "2023-05-26T09:39:22.980282Z", + "iopub.status.busy": "2023-05-26T09:39:22.979405Z", + "iopub.status.idle": "2023-05-26T09:39:23.099441Z", + "shell.execute_reply": "2023-05-26T09:39:23.098684Z", + "shell.execute_reply.started": "2023-05-26T09:39:22.980241Z" }, "tags": [] }, @@ -388,12 +388,12 @@ "import yaml\n", "import json\n", "\n", - "filename = 'data/全维健康职工心理测评量表.yml'\n", + "filename = 'data/西藏石油中医、心理测评量表.yaml'\n", "with open(filename, 'r', encoding='utf-8') as f:\n", " result = yaml.load(f.read(), Loader=yaml.FullLoader)\n", "i = 1\n", "#print(result)\n", - "filename = 'data/全维健康职工心理测评量表.json'\n", + "filename = 'data/西藏石油中医、心理测评量表.json'\n", "with open(filename, 'w') as fl:\n", " json.dump(result, fl, ensure_ascii=False)\n", "print('ok')"