20231027
This commit is contained in:
1 parent
80d40619c1
commit
a00eae7487
2 files changed
+712
-21
No files matched your search
+693
-2
@@ -4,7 +4,9 @@
|
||||
"cell_type": "markdown",
|
||||
"id": "19280f5c-8e34-4a64-8dfb-6353cbf597d2",
|
||||
"metadata": {
|
||||
"tags": []
|
||||
"jp-MarkdownHeadingCollapsed": true,
|
||||
"tags": [],
|
||||
"toc-hr-collapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# 体质检测数据处理"
|
||||
@@ -619,7 +621,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "732161bb-98f2-4861-ab66-7a374678bcd8",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"toc-hr-collapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# 体质检测数据管理"
|
||||
]
|
||||
@@ -1201,6 +1205,693 @@
|
||||
"print(unit)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5780368e-59c7-4bc1-a130-21b2f7da23de",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 体质测试综合报告数据分析"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "0ddf1a23-5963-43ba-9166-c88be749d75d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 清理报告数据"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 19,
|
||||
"id": "46aa847d-e1fe-45bd-85b6-e2d792ec8842",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:39:19.221686Z",
|
||||
"iopub.status.busy": "2023-10-27T02:39:19.220179Z",
|
||||
"iopub.status.idle": "2023-10-27T02:39:19.596125Z",
|
||||
"shell.execute_reply": "2023-10-27T02:39:19.595375Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:39:19.221609Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/result_天津231017.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
" \n",
|
||||
"#items = ['身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"items = {}\n",
|
||||
"items['lung'] = '肺活量'\n",
|
||||
"items['grip'] ='握力'\n",
|
||||
"items['flexion'] ='坐位体前屈'\n",
|
||||
"items['jump'] ='纵跳'\n",
|
||||
"items['pushup'] ='俯卧撑'\n",
|
||||
"items['balance'] ='单脚站立'\n",
|
||||
"items['reaction'] ='选择反应时'\n",
|
||||
"items['step'] ='台阶指数'\n",
|
||||
"items['situp'] ='一分钟仰卧起坐'\n",
|
||||
"items['bmi'] ='BMI'\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"list1 = []\n",
|
||||
"fiie_path ='./134/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i=1\n",
|
||||
"list2 = []\n",
|
||||
"dict2 = {}\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list1 = []\n",
|
||||
" mydata = {}\n",
|
||||
" \n",
|
||||
" id = str(k).rjust(8,\"0\")\n",
|
||||
" mydata['unit'] = v['unit']\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" mydata['sex'] = v['sex']\n",
|
||||
" mydata['month'] = v['month']\n",
|
||||
" age = int(v['month']/12)\n",
|
||||
" if age <20:\n",
|
||||
" mydata['age'] = 20\n",
|
||||
" else:\n",
|
||||
" mydata['age'] = int(v['month']/12)\n",
|
||||
" \n",
|
||||
" mydata['fits'] = {}\n",
|
||||
" score = 0\n",
|
||||
" for item in list_item:\n",
|
||||
" if item in v.keys():\n",
|
||||
" if item in ['lung','pushup','step','situp']:\n",
|
||||
" mark = v[item]['成绩'].split()[0].split('.')[0]\n",
|
||||
" else:\n",
|
||||
" mark = v[item]['成绩'].split()[0]\n",
|
||||
" mydata['fits'][items[item]] = {'mark':mark,'score':v[item]['score']}\n",
|
||||
" score = score + v[item]['score']\n",
|
||||
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
|
||||
" if len(mydata['fits']) >2:\n",
|
||||
" dict2[str(k)] = mydata\n",
|
||||
"filename = f'data/data_天津231017.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ed5f157a-3114-4221-907d-53ce62409d83",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 计算平均成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 28,
|
||||
"id": "63edd636-f034-4aa6-8575-63d5cdb84adb",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:49:58.190922Z",
|
||||
"iopub.status.busy": "2023-10-27T02:49:58.190633Z",
|
||||
"iopub.status.idle": "2023-10-27T02:49:58.268977Z",
|
||||
"shell.execute_reply": "2023-10-27T02:49:58.268090Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:49:58.190898Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"平均成绩:2.4704分,男性:3788人\n",
|
||||
"平均成绩:2.8269分,女性:1595人\n",
|
||||
"平均成绩:2.576分,总体:5383人\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",
|
||||
"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/5383,4)}分,总体:5383人')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3277b104-9b53-41c4-9b9a-f9acb71dbce1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 计算测试等级"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 31,
|
||||
"id": "1b4a3f02-9b2e-41fc-ac6c-8163907a07f1",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:58:06.779955Z",
|
||||
"iopub.status.busy": "2023-10-27T02:58:06.779651Z",
|
||||
"iopub.status.idle": "2023-10-27T02:58:07.075493Z",
|
||||
"shell.execute_reply": "2023-10-27T02:58:07.074963Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:58:06.779929Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0~255分人数:2524人,男性:2056人,女性:468人\n",
|
||||
"256~332分人数:2214人,男性:1400人,女性:814人\n",
|
||||
"333~367分人数:495人,男性:274人,女性:221人\n",
|
||||
"368~500分人数:150人,男性:58人,女性:92人\n",
|
||||
"5383\n",
|
||||
"ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/data_天津231017.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",
|
||||
"print(len(dict1))\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict1, fl) \n",
|
||||
"print('ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "39a1239d-13d8-4583-a163-e6db98c3933b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算各年龄段测试等级(女)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 32,
|
||||
"id": "2d661ca6-6129-4da1-ac25-51d0156babb2",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:58:18.805947Z",
|
||||
"iopub.status.busy": "2023-10-27T02:58:18.805660Z",
|
||||
"iopub.status.idle": "2023-10-27T02:58:18.884931Z",
|
||||
"shell.execute_reply": "2023-10-27T02:58:18.884363Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:58:18.805924Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20-24 {'不合格': 131, '合格': 177, '良好': 25, '优秀': 5}\n",
|
||||
"25-29 {'不合格': 54, '良好': 21, '合格': 90, '优秀': 3}\n",
|
||||
"30-34 {'不合格': 14, '合格': 46, '良好': 11, '优秀': 4}\n",
|
||||
"35-39 {'不合格': 30, '良好': 32, '合格': 77, '优秀': 8}\n",
|
||||
"40-44 {'不合格': 46, '合格': 84, '优秀': 12, '良好': 24}\n",
|
||||
"45-49 {'合格': 204, '不合格': 112, '良好': 69, '优秀': 32}\n",
|
||||
"50-54 {'合格': 136, '不合格': 81, '优秀': 28, '良好': 39}\n",
|
||||
"55-80 {'合格': 0, '不合格': 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",
|
||||
"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": "b7d10bef-405f-49a1-b423-2b972b4d1a44",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算各年龄段测试等级(男)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 33,
|
||||
"id": "fc97df37-34ff-4a02-9d26-b5d81b706e46",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:59:02.314552Z",
|
||||
"iopub.status.busy": "2023-10-27T02:59:02.313742Z",
|
||||
"iopub.status.idle": "2023-10-27T02:59:02.387081Z",
|
||||
"shell.execute_reply": "2023-10-27T02:59:02.386535Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:59:02.314476Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20-24 {'不合格': 426, '合格': 240, '良好': 34, '优秀': 6}\n",
|
||||
"25-29 {'不合格': 196, '良好': 34, '合格': 138, '优秀': 4}\n",
|
||||
"30-34 {'不合格': 90, '合格': 59, '良好': 13, '优秀': 3}\n",
|
||||
"35-39 {'不合格': 171, '良好': 33, '合格': 119, '优秀': 5}\n",
|
||||
"40-44 {'不合格': 114, '合格': 103, '优秀': 6, '良好': 22}\n",
|
||||
"45-49 {'合格': 179, '不合格': 245, '良好': 39, '优秀': 3}\n",
|
||||
"50-54 {'合格': 345, '不合格': 502, '优秀': 22, '良好': 60}\n",
|
||||
"55-80 {'合格': 217, '不合格': 312, '良好': 39, '优秀': 9}\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": "466355fe-5939-463c-a31e-a3a1beb4e78b",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 根据年龄汇总人员信息及成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "dafb86f8-5ee0-4c87-a98f-c7ff0f631fe5",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:42:53.065561Z",
|
||||
"iopub.status.busy": "2023-10-27T02:42:53.065280Z",
|
||||
"iopub.status.idle": "2023-10-27T02:42:53.141524Z",
|
||||
"shell.execute_reply": "2023-10-27T02:42:53.140901Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:42:53.065537Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"16~24岁平均成绩:2.47分,人数:1044人,男性:706人\n",
|
||||
"25~29岁平均成绩:2.58分,人数:540人,男性:372人\n",
|
||||
"30~34岁平均成绩:2.6分,人数:240人,男性:165人\n",
|
||||
"35~39岁平均成绩:2.64分,人数:475人,男性:328人\n",
|
||||
"40~44岁平均成绩:2.69分,人数:411人,男性:245人\n",
|
||||
"45~49岁平均成绩:2.68分,人数:883人,男性:466人\n",
|
||||
"50~54岁平均成绩:2.57分,人数:1213人,男性:929人\n",
|
||||
"55~69岁平均成绩:2.48分,人数:577人,男性:577人\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"nld = [[16,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,69]]\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 = 0\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",
|
||||
" if i ==0:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:0分,人数:0人,男性:{m}人')\n",
|
||||
" else:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人,男性:{m}人')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "dafdffca-6543-4304-af61-4f7cd418ba24",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 根据年龄汇总人员信息及成绩(男)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 26,
|
||||
"id": "347703a1-501b-4800-bd29-16e94f4a6793",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:46:37.747375Z",
|
||||
"iopub.status.busy": "2023-10-27T02:46:37.747078Z",
|
||||
"iopub.status.idle": "2023-10-27T02:46:37.815689Z",
|
||||
"shell.execute_reply": "2023-10-27T02:46:37.814984Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:46:37.747349Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20~24岁平均成绩:2.39分,人数:706人\n",
|
||||
"25~29岁平均成绩:2.5分,人数:372人\n",
|
||||
"30~34岁平均成绩:2.47分,人数:165人\n",
|
||||
"35~39岁平均成绩:2.5分,人数:328人\n",
|
||||
"40~44岁平均成绩:2.57分,人数:245人\n",
|
||||
"45~49岁平均成绩:2.48分,人数:466人\n",
|
||||
"50~54岁平均成绩:2.47分,人数:929人\n",
|
||||
"55~80岁平均成绩:2.48分,人数:577人\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"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 = 0\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",
|
||||
" if i ==0:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:0分,人数:{i}人') \n",
|
||||
" else:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9b63891e-824a-4772-83f9-0706381ffd14",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 根据年龄汇总人员信息及成绩(女)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 27,
|
||||
"id": "5900d1c7-2f8c-4dfa-a60e-a577fb90f22d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:47:40.422207Z",
|
||||
"iopub.status.busy": "2023-10-27T02:47:40.421915Z",
|
||||
"iopub.status.idle": "2023-10-27T02:47:40.532803Z",
|
||||
"shell.execute_reply": "2023-10-27T02:47:40.532106Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:47:40.422184Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20~24岁平均成绩:2.65分,人数:338人\n",
|
||||
"25~29岁平均成绩:2.74分,人数:168人\n",
|
||||
"30~34岁平均成绩:2.88分,人数:75人\n",
|
||||
"35~39岁平均成绩:2.95分,人数:147人\n",
|
||||
"40~44岁平均成绩:2.85分,人数:166人\n",
|
||||
"45~49岁平均成绩:2.9分,人数:417人\n",
|
||||
"50~54岁平均成绩:2.89分,人数:284人\n",
|
||||
"55~80岁平均成绩: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 = 0\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",
|
||||
" if i ==0:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:0分,人数:{i}人') \n",
|
||||
" else:\n",
|
||||
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i}人')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ca546652-d275-46d3-9b9a-9cb1c3a09a78",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 计算各项目成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 34,
|
||||
"id": "ad69c45d-3f62-42df-894d-47424e759029",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T02:59:52.525939Z",
|
||||
"iopub.status.busy": "2023-10-27T02:59:52.525661Z",
|
||||
"iopub.status.idle": "2023-10-27T02:59:52.682642Z",
|
||||
"shell.execute_reply": "2023-10-27T02:59:52.681750Z",
|
||||
"shell.execute_reply.started": "2023-10-27T02:59:52.525915Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"BMI 3.53 5344\n",
|
||||
"肺活量 3.3 5270\n",
|
||||
"握力 1.36 5291\n",
|
||||
"坐位体前屈 2.87 4581\n",
|
||||
"纵跳 1.93 4632\n",
|
||||
"俯卧撑 2.49 3085\n",
|
||||
"一分钟仰卧起坐 3.85 1034\n",
|
||||
"单脚站立 1.96 5180\n",
|
||||
"选择反应时 2.93 5300\n",
|
||||
"台阶指数 2.6 2164\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"items = ['BMI','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"for item in items:\n",
|
||||
" score = 0\n",
|
||||
" n = 0\n",
|
||||
" for k, v in dict1.items(): \n",
|
||||
" if item in v['fits'].keys():\n",
|
||||
" n = n + 1\n",
|
||||
" score =score + int(v['fits'][item]['score'])\n",
|
||||
" print(item,round(score/n,2),n)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "f005328b-1927-4f62-b530-e7750299c423",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 按照部门计算平均成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 35,
|
||||
"id": "dcf152e7-bbcc-47d1-9c5f-83854db35412",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-27T03:04:24.035897Z",
|
||||
"iopub.status.busy": "2023-10-27T03:04:24.035597Z",
|
||||
"iopub.status.idle": "2023-10-27T03:04:24.127211Z",
|
||||
"shell.execute_reply": "2023-10-27T03:04:24.126568Z",
|
||||
"shell.execute_reply.started": "2023-10-27T03:04:24.035871Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"化验计量部 2.56 469\n",
|
||||
"南港烯烃部 2.48 681\n",
|
||||
"消防支队 2.52 72\n",
|
||||
"炼油部 2.63 1191\n",
|
||||
"化工部 2.58 522\n",
|
||||
"电仪部 2.4 322\n",
|
||||
"物资采购中心 2.67 84\n",
|
||||
"水务部 2.53 396\n",
|
||||
"运输销售部 2.44 199\n",
|
||||
"原油储运部 2.5 178\n",
|
||||
"聚醚部 2.63 112\n",
|
||||
"公司机关 2.65 112\n",
|
||||
"南港乙烯项目管理部 2.61 15\n",
|
||||
"党委党校(培训中心) 2.79 48\n",
|
||||
"装备研究院 2.71 48\n",
|
||||
"热电部 2.63 412\n",
|
||||
"烯烃部 2.63 320\n",
|
||||
"行政事务中心 2.6 41\n",
|
||||
"信息档案管理中心 2.84 60\n",
|
||||
"研究院 2.82 101\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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "46997480-54dd-440f-83a1-0e946d7463f7",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "d1977ca9-bf12-4f09-ae7b-e8af9eaa82f2",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bdb81e20-32ec-4e0e-b2ac-13dac2060068",
|
||||
|
||||
Reference in new issue
Block a user