This commit is contained in:
512song committed 2023-10-25 07:45:59 +00:00
1 parent 9b8fac651e
commit ceda991559
2 files changed
+917 -4

No files matched your search

+499 -1
View File
@@ -2332,10 +2332,508 @@
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "85a03b00-9624-4ae9-aa6d-386798d457df",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T02:50:56.997544Z",
"iopub.status.busy": "2023-10-25T02:50:56.995911Z",
"iopub.status.idle": "2023-10-25T02:50:57.006678Z",
"shell.execute_reply": "2023-10-25T02:50:57.004773Z",
"shell.execute_reply.started": "2023-10-25T02:50:56.997463Z"
},
"tags": []
},
"source": [
"# 体测数据分析"
]
},
{
"cell_type": "markdown",
"id": "dca06570-73e6-4f60-8cf9-b3f9da64f1c4",
"metadata": {},
"source": [
"## 清理报告数据"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "f9fee64f-41ff-4453-8a32-a33df086022e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:50:48.179535Z",
"iopub.status.busy": "2023-10-25T03:50:48.179245Z",
"iopub.status.idle": "2023-10-25T03:50:48.598995Z",
"shell.execute_reply": "2023-10-25T03:50:48.598421Z",
"shell.execute_reply.started": "2023-10-25T03:50:48.179514Z"
},
"tags": []
},
"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": "bd1f8f42-c14a-4bb7-8656-14a0f7968cfc",
"metadata": {},
"source": [
"## 计算测试等级"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "006afc6c-2b1f-4edf-be1b-5f60e2029ee8",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:50:53.233122Z",
"iopub.status.busy": "2023-10-25T03:50:53.232833Z",
"iopub.status.idle": "2023-10-25T03:50:53.316856Z",
"shell.execute_reply": "2023-10-25T03:50:53.316327Z",
"shell.execute_reply.started": "2023-10-25T03:50:53.233097Z"
},
"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"
]
}
],
"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))"
]
},
{
"cell_type": "markdown",
"id": "ed3c0653-087a-4a9d-ba21-8cf5f48515d9",
"metadata": {},
"source": [
"## 根据年龄汇总人员信息及成绩"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "949e4c3c-023d-44a4-b99e-c5460da61161",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:50:55.994714Z",
"iopub.status.busy": "2023-10-25T03:50:55.994442Z",
"iopub.status.idle": "2023-10-25T03:50:56.087067Z",
"shell.execute_reply": "2023-10-25T03:50:56.086443Z",
"shell.execute_reply.started": "2023-10-25T03:50:55.994689Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.47分,人数:1044人,男性:706人\n",
"25~29岁平均成绩:2.57分,人数:540人,男性:372人\n",
"30~34岁平均成绩:2.59分,人数:240人,男性:165人\n",
"35~39岁平均成绩:2.63分,人数:475人,男性:328人\n",
"40~44岁平均成绩:2.68分,人数:411人,男性:245人\n",
"45~49岁平均成绩:2.67分,人数:883人,男性:466人\n",
"50~54岁平均成绩:2.57分,人数:1213人,男性:929人\n",
"55~69岁平均成绩:2.48分,人数:577人,男性:577人\n"
]
}
],
"source": [
"nld = [[20,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 = 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": "6a967a44-7c12-4e82-827b-d75926c09e77",
"metadata": {},
"source": [
"### 根据年龄汇总人员信息及成绩(男)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "721977d3-5816-4bf6-82fc-26fd170e5454",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:51:22.393382Z",
"iopub.status.busy": "2023-10-25T03:51:22.393098Z",
"iopub.status.idle": "2023-10-25T03:51:22.503597Z",
"shell.execute_reply": "2023-10-25T03:51:22.502884Z",
"shell.execute_reply.started": "2023-10-25T03:51:22.393358Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.38分,人数:706人\n",
"25~29岁平均成绩:2.5分,人数:372人\n",
"30~34岁平均成绩:2.46分,人数:165人\n",
"35~39岁平均成绩:2.49分,人数:328人\n",
"40~44岁平均成绩:2.56分,人数:245人\n",
"45~49岁平均成绩:2.47分,人数: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 = 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": "3a8f747e-aacd-45bf-b94a-b505cfd31922",
"metadata": {},
"source": [
"### 根据年龄汇总人员信息及成绩(女)"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "f493dc0a-d3cd-4dbd-ad35-e06eb96afbc5",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:51:25.001730Z",
"iopub.status.busy": "2023-10-25T03:51:25.001459Z",
"iopub.status.idle": "2023-10-25T03:51:25.099310Z",
"shell.execute_reply": "2023-10-25T03:51:25.098566Z",
"shell.execute_reply.started": "2023-10-25T03:51:25.001706Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:2.65分,人数:338人\n",
"25~29岁平均成绩:2.72分,人数:168人\n",
"30~34岁平均成绩:2.84分,人数:75人\n",
"35~39岁平均成绩:2.93分,人数:147人\n",
"40~44岁平均成绩:2.83分,人数:166人\n",
"45~49岁平均成绩:2.89分,人数:417人\n",
"50~54岁平均成绩:2.88分,人数:284人\n",
"55~80岁平均成绩:0.0分,人数:0人\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 = 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": "e9c6bd2e-b6ac-4a6f-ba28-aafcabb40c0d",
"metadata": {},
"source": [
"## 计算平均成绩"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "7155f2c2-0719-4558-aa3b-629fb70194d6",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:51:48.682998Z",
"iopub.status.busy": "2023-10-25T03:51:48.682686Z",
"iopub.status.idle": "2023-10-25T03:51:48.834661Z",
"shell.execute_reply": "2023-10-25T03:51:48.834139Z",
"shell.execute_reply.started": "2023-10-25T03:51:48.682964Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"平均成绩:2.4704分,男性:3788人\n",
"平均成绩:2.8269分,女性:1595人\n",
"平均成绩:2.576分,总体:5383人\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/5383,4)}分,总体:5383人')"
]
},
{
"cell_type": "markdown",
"id": "9a544eec-ec58-47dc-aa36-d890b0b309c2",
"metadata": {},
"source": [
"## 计算测试等级"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "a0bbb339-ee4e-4dc1-83ec-b2055e3c670e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-10-25T03:52:43.358905Z",
"iopub.status.busy": "2023-10-25T03:52:43.358608Z",
"iopub.status.idle": "2023-10-25T03:52:43.644315Z",
"shell.execute_reply": "2023-10-25T03:52:43.643658Z",
"shell.execute_reply.started": "2023-10-25T03:52:43.358879Z"
},
"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",
"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": "92103efb-a3e4-43ec-acfb-e4cb0b07c2fb",
"metadata": {},
"source": [
"## 计算各年龄段测试等级(女)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8157084e-67a1-48d9-a3c2-34ea8b170039",
"id": "f8949993-7501-4359-aa7c-2cd5de348056",
"metadata": {},
"outputs": [],
"source": []