20231026
This commit is contained in:
1 parent
ce3d665870
commit
80d40619c1
2 files changed
+697
-55
No files matched your search
+696
-55
@@ -488,6 +488,7 @@
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"\n",
|
||||
"filename = 'data/result_政法委new.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
@@ -503,7 +504,7 @@
|
||||
" if 'phone' in v.keys():\n",
|
||||
" phone.add(v['phone'])\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20231023-1698026051370.csv'\n",
|
||||
"filename = 'data/Survey_20231026.csv'\n",
|
||||
"with open(filename,'r',newline='') as csv_file:\n",
|
||||
" fl = csv.reader(csv_file,delimiter=',')\n",
|
||||
" header = next(fl) \n",
|
||||
@@ -511,8 +512,10 @@
|
||||
" #line = re.sub('[\\r\\n\\f ]{1,}', '', line)\n",
|
||||
" list1.append(line)\n",
|
||||
"dict2 = {}\n",
|
||||
"m_rq = '2023-10-20'\n",
|
||||
"rq= date.fromisoformat(m_rq.replace('/','-'))\n",
|
||||
"for item in list1:\n",
|
||||
" if item[2] in phone:\n",
|
||||
" if item[2] in phone: \n",
|
||||
" content = json.loads(item[5])\n",
|
||||
" list2 = []\n",
|
||||
" for i in range(0,60):\n",
|
||||
@@ -524,8 +527,15 @@
|
||||
"print(dict2) \n",
|
||||
"for k, v in dict3.items():\n",
|
||||
" if 'phone' in v.keys() and v['phone'] in dict2.keys():\n",
|
||||
" if k not in dict1.keys():\n",
|
||||
" dict1.setdefault(k,{})\n",
|
||||
" dict1[k] = dict3[k]\n",
|
||||
" days = (rq-birth).days \n",
|
||||
" dict1[k]['age'] = int(days/365)\n",
|
||||
" dict1[k]['month'] = int(days/365*12)\n",
|
||||
" \n",
|
||||
" dict1[k]['tcm'] = dict2[str(v['phone'])]\n",
|
||||
" \n",
|
||||
" \n",
|
||||
"filename = 'data/result_政法委new.json'\n",
|
||||
"\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
@@ -630,51 +640,12 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"execution_count": null,
|
||||
"id": "ab9b8e0c-53dd-4b93-a42a-7d1952b0423a",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-23T05:17:28.469311Z",
|
||||
"iopub.status.busy": "2023-10-23T05:17:28.468525Z",
|
||||
"iopub.status.idle": "2023-10-23T05:17:37.469379Z",
|
||||
"shell.execute_reply": "2023-10-23T05:17:37.468756Z",
|
||||
"shell.execute_reply.started": "2023-10-23T05:17:28.469237Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"041 尚建红 {\"errmsg\":\"ok\"}\n",
|
||||
"043 刘玉琴 {\"errmsg\":\"ok\"}\n",
|
||||
"044 姚晓颖 {\"errmsg\":\"ok\"}\n",
|
||||
"045 李秀梅 {\"errmsg\":\"ok\"}\n",
|
||||
"042 杨坡 {\"errmsg\":\"ok\"}\n",
|
||||
"018 吴颖 {\"errmsg\":\"ok\"}\n",
|
||||
"002 杜国华 {\"errmsg\":\"ok\"}\n",
|
||||
"004 赵玉龙 {\"errmsg\":\"ok\"}\n",
|
||||
"008 袁艳华 {\"errmsg\":\"ok\"}\n",
|
||||
"006 李娟 {\"errmsg\":\"ok\"}\n",
|
||||
"011 武利平 {\"errmsg\":\"ok\"}\n",
|
||||
"019 朱牧然 {\"errmsg\":\"ok\"}\n",
|
||||
"022 王建峰 {\"errmsg\":\"ok\"}\n",
|
||||
"021 朱雪峰 {\"errmsg\":\"ok\"}\n",
|
||||
"020 王往 {\"errmsg\":\"ok\"}\n",
|
||||
"029 赵路扬 {\"errmsg\":\"ok\"}\n",
|
||||
"030 张世涵 {\"errmsg\":\"ok\"}\n",
|
||||
"031 刘苗苗 {\"errmsg\":\"ok\"}\n",
|
||||
"032 王立军 {\"errmsg\":\"ok\"}\n",
|
||||
"016 刘畅 {\"errmsg\":\"ok\"}\n",
|
||||
"012 李春光 {\"errmsg\":\"ok\"}\n",
|
||||
"014 梁艺 {\"errmsg\":\"ok\"}\n",
|
||||
"017 程荣荣 {\"errmsg\":\"ok\"}\n",
|
||||
"033 张和平 {\"errmsg\":\"ok\"}\n",
|
||||
"015 李超 {\"errmsg\":\"ok\"}\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import requests\n",
|
||||
"import json\n",
|
||||
@@ -688,7 +659,7 @@
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"list1 = []\n",
|
||||
"fiie_path ='./政法委/'\n",
|
||||
"fiie_path ='./政法委1/'\n",
|
||||
"list_item = ['lung','grip','flexion','jump','pushup','balance','reaction','step','situp','bmi']\n",
|
||||
"i = 27\n",
|
||||
"list2 = []\n",
|
||||
@@ -697,8 +668,8 @@
|
||||
" mydata = {} \n",
|
||||
" id = k.rjust(3,\"0\")\n",
|
||||
" mydata['path'] = fiie_path+id+'-'+ v['name']+'.pdf'\n",
|
||||
" mydata['title'] = '政法委'\n",
|
||||
" mydata['subtitle'] = v['unit']\n",
|
||||
" mydata['title'] = '延庆区委政法委'\n",
|
||||
" #mydata['subtitle'] = ''\n",
|
||||
" mydata['id'] = id\n",
|
||||
" mydata['name'] = v['name']\n",
|
||||
" if v['sex'] == '男':\n",
|
||||
@@ -712,6 +683,7 @@
|
||||
" mydata['surveys']['tcm'] = v['tcm']\n",
|
||||
" \n",
|
||||
" mydata['fits'] = {}\n",
|
||||
" #mydata.setdefault('fits',{})\n",
|
||||
" for item in list_item:\n",
|
||||
" if item in dict1[k].keys():\n",
|
||||
" if item in ['lung','pushup','step','situp']:\n",
|
||||
@@ -719,19 +691,688 @@
|
||||
" else:\n",
|
||||
" mark = dict1[k][item]['成绩'].split()[0]\n",
|
||||
" mydata['fits'][item] = {'mark':mark,'score':dict1[k][item]['score']}\n",
|
||||
" if len(mydata['fits']) >2: \n",
|
||||
" list1.append(mydata)\n",
|
||||
" list2.append([k,dict1[k]['name']])\n",
|
||||
" x = requests.post('http://192.168.1.148:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" print(id,dict1[k]['name'],x.text)\n",
|
||||
" #x.close()\n",
|
||||
" #print(mydata)\n"
|
||||
" #print(mydata) \n",
|
||||
" \n",
|
||||
" list1.append(mydata)\n",
|
||||
" #list2.append([k,dict1[k]['name']])\n",
|
||||
"\n",
|
||||
" x = requests.post('http://localhost:3003', data = json.dumps(list1), headers=headers)\n",
|
||||
" print(id,dict1[k]['name'],x.text)\n",
|
||||
" x.close()\n",
|
||||
" #print(mydata)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "fd349cad-ac40-4f35-8eb3-3642a9a82899",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 数据分析"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "187d68b0-f404-489f-8c42-1ae98139ac5c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 清理报告数据"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 95,
|
||||
"id": "8da85b6e-6a8e-4552-ac9b-475986520edb",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:35:28.101067Z",
|
||||
"iopub.status.busy": "2023-10-26T03:35:28.100567Z",
|
||||
"iopub.status.idle": "2023-10-26T03:35:28.134546Z",
|
||||
"shell.execute_reply": "2023-10-26T03:35:28.131755Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:35:28.101019Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"ok!\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"filename = 'data/result_政法委new.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",
|
||||
"\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(3,\"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",
|
||||
" n+=1\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",
|
||||
" \n",
|
||||
" #mydata['score'] = round(score/len(mydata['fits']),2)\n",
|
||||
" if len(mydata['fits']) >2:\n",
|
||||
" mydata['score'] = round(score/len(mydata['fits']),2)\n",
|
||||
" dict2[str(k)] = mydata\n",
|
||||
"filename = f'data/data_政法委.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(dict2,fl , ensure_ascii=False) \n",
|
||||
"print('ok!') "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a6539755-2418-452c-a8c2-73330e7a074c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算测试等级"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 96,
|
||||
"id": "e37fb523-af73-42b7-8b74-c91cbfa0e0d7",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:49:05.366546Z",
|
||||
"iopub.status.busy": "2023-10-26T03:49:05.366264Z",
|
||||
"iopub.status.idle": "2023-10-26T03:49:05.373556Z",
|
||||
"shell.execute_reply": "2023-10-26T03:49:05.373033Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:49:05.366520Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0~255分人数:4人,男性:4人,女性:0人\n",
|
||||
"256~332分人数:13人,男性:5人,女性:8人\n",
|
||||
"333~367分人数:5人,男性:1人,女性:4人\n",
|
||||
"368~500分人数:3人,男性:1人,女性:2人\n",
|
||||
"25\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"\n",
|
||||
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/data_政法委.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": "6c1632a4-3bd5-4f63-9593-7675272725ad",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 根据年龄汇总人员信息及成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 112,
|
||||
"id": "c12bc25a-17d6-4dcf-b739-cfa9bbe4410f",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T04:23:58.525630Z",
|
||||
"iopub.status.busy": "2023-10-26T04:23:58.525352Z",
|
||||
"iopub.status.idle": "2023-10-26T04:23:58.532045Z",
|
||||
"shell.execute_reply": "2023-10-26T04:23:58.531567Z",
|
||||
"shell.execute_reply.started": "2023-10-26T04:23:58.525606Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20~24岁平均成绩:0分,人数:0人,男性:0人\n",
|
||||
"25~29岁平均成绩:2.22分,人数:0人,男性:1人\n",
|
||||
"30~34岁平均成绩:3.0分,人数:4人,男性:3人\n",
|
||||
"35~39岁平均成绩:2.99分,人数:5人,男性:2人\n",
|
||||
"40~44岁平均成绩:2.96分,人数:5人,男性:2人\n",
|
||||
"45~49岁平均成绩:3.5分,人数:3人,男性:1人\n",
|
||||
"50~54岁平均成绩:3.18分,人数:2人,男性:2人\n",
|
||||
"55~69岁平均成绩:0分,人数:0人,男性:0人\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 = 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": "3c7b8dd3-ca80-45dc-92ae-6832e3c2dbcb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 根据年龄汇总人员信息及成绩(男)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 114,
|
||||
"id": "eec3966b-91ec-4527-86a6-2e5ced6ba002",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T04:25:42.987343Z",
|
||||
"iopub.status.busy": "2023-10-26T04:25:42.986782Z",
|
||||
"iopub.status.idle": "2023-10-26T04:25:43.001560Z",
|
||||
"shell.execute_reply": "2023-10-26T04:25:43.000037Z",
|
||||
"shell.execute_reply.started": "2023-10-26T04:25:42.987293Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20~24岁平均成绩:0分,人数:0人\n",
|
||||
"25~29岁平均成绩:2.22分,人数:1人\n",
|
||||
"30~34岁平均成绩:2.96分,人数:3人\n",
|
||||
"35~39岁平均成绩:2.54分,人数:2人\n",
|
||||
"40~44岁平均成绩:2.82分,人数:2人\n",
|
||||
"45~49岁平均成绩:2.89分,人数:1人\n",
|
||||
"50~54岁平均成绩:3.17分,人数:2人\n",
|
||||
"55~80岁平均成绩: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 = 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": "1277bad3-b04c-4d66-865f-fa6dc3b2bf61",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 根据年龄汇总人员信息及成绩(女)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 116,
|
||||
"id": "40658342-1628-42a5-89ad-85fe592e74bb",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T04:26:12.879285Z",
|
||||
"iopub.status.busy": "2023-10-26T04:26:12.878016Z",
|
||||
"iopub.status.idle": "2023-10-26T04:26:12.905340Z",
|
||||
"shell.execute_reply": "2023-10-26T04:26:12.902439Z",
|
||||
"shell.execute_reply.started": "2023-10-26T04:26:12.879163Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20~24岁平均成绩:0分,人数:0人\n",
|
||||
"25~29岁平均成绩:0分,人数:0人\n",
|
||||
"30~34岁平均成绩:3.06分,人数:2人\n",
|
||||
"35~39岁平均成绩:3.21分,人数:4人\n",
|
||||
"40~44岁平均成绩:3.03分,人数:4人\n",
|
||||
"45~49岁平均成绩:3.7分,人数:3人\n",
|
||||
"50~54岁平均成绩:3.22分,人数:1人\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": "a59a8699-1a62-43ca-a11d-cdc03009b9e1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算平均成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 100,
|
||||
"id": "899da5d8-708e-4bb8-a1ce-b82a40cf2e94",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:51:52.546011Z",
|
||||
"iopub.status.busy": "2023-10-26T03:51:52.545203Z",
|
||||
"iopub.status.idle": "2023-10-26T03:51:52.568280Z",
|
||||
"shell.execute_reply": "2023-10-26T03:51:52.566286Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:51:52.545933Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"平均成绩:2.8227分,男性:11人\n",
|
||||
"平均成绩:3.2429分,女性:14人\n",
|
||||
"平均成绩:3.058分,总体:25人\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/25,4)}分,总体:25人')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "314ca97d-ad3e-4fe0-a6a5-45b8de94f71e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算测试等级"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 101,
|
||||
"id": "dfb1b1f1-79fd-47af-9fdb-3671de26a17d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:52:27.216766Z",
|
||||
"iopub.status.busy": "2023-10-26T03:52:27.216454Z",
|
||||
"iopub.status.idle": "2023-10-26T03:52:27.237182Z",
|
||||
"shell.execute_reply": "2023-10-26T03:52:27.234980Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:52:27.216738Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"0~255分人数:4人,男性:4人,女性:0人\n",
|
||||
"256~332分人数:13人,男性:5人,女性:8人\n",
|
||||
"333~367分人数:5人,男性:1人,女性:4人\n",
|
||||
"368~500分人数:3人,男性:1人,女性:2人\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": "fe71a0f0-5494-4462-a123-d0edbbaaf3ab",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算各年龄段测试等级(女)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 102,
|
||||
"id": "5af094da-db54-4ab7-bbce-7329cb2fc1b1",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:53:27.018083Z",
|
||||
"iopub.status.busy": "2023-10-26T03:53:27.017773Z",
|
||||
"iopub.status.idle": "2023-10-26T03:53:27.025537Z",
|
||||
"shell.execute_reply": "2023-10-26T03:53:27.025061Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:53:27.018054Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20-24 {}\n",
|
||||
"25-29 {'不合格': 0}\n",
|
||||
"30-34 {'良好': 1, '不合格': 0, '合格': 1}\n",
|
||||
"35-39 {'合格': 2, '良好': 2, '不合格': 0}\n",
|
||||
"40-44 {'合格': 3, '良好': 1}\n",
|
||||
"45-49 {'优秀': 2, '合格': 1}\n",
|
||||
"50-54 {'不合格': 0, '优秀': 0, '合格': 1}\n",
|
||||
"55-80 {}\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": "ee7396bd-6548-4aaf-8b6d-53a4fa5f2f56",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算各年龄段测试等级(男)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 103,
|
||||
"id": "38c51c24-3f9e-4147-9743-19d4f07bc2ff",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T03:54:08.316734Z",
|
||||
"iopub.status.busy": "2023-10-26T03:54:08.316430Z",
|
||||
"iopub.status.idle": "2023-10-26T03:54:08.324322Z",
|
||||
"shell.execute_reply": "2023-10-26T03:54:08.323799Z",
|
||||
"shell.execute_reply.started": "2023-10-26T03:54:08.316708Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20-24 {}\n",
|
||||
"25-29 {'不合格': 1}\n",
|
||||
"30-34 {'良好': 1, '不合格': 1, '合格': 1}\n",
|
||||
"35-39 {'合格': 1, '良好': 0, '不合格': 1}\n",
|
||||
"40-44 {'合格': 2, '良好': 0}\n",
|
||||
"45-49 {'优秀': 0, '合格': 1}\n",
|
||||
"50-54 {'不合格': 1, '优秀': 1, '合格': 0}\n",
|
||||
"55-80 {}\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": "0921bc7f-984e-4aaf-8c3b-8bf9f086c804",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### 计算各项目成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 117,
|
||||
"id": "229640d7-824b-4cb2-bdec-7d884677a856",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2023-10-26T05:03:47.686725Z",
|
||||
"iopub.status.busy": "2023-10-26T05:03:47.685887Z",
|
||||
"iopub.status.idle": "2023-10-26T05:03:47.706507Z",
|
||||
"shell.execute_reply": "2023-10-26T05:03:47.704152Z",
|
||||
"shell.execute_reply.started": "2023-10-26T05:03:47.686645Z"
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"BMI 3.8 25\n",
|
||||
"肺活量 3.68 25\n",
|
||||
"握力 2.56 25\n",
|
||||
"坐位体前屈 2.88 25\n",
|
||||
"纵跳 2.44 25\n",
|
||||
"俯卧撑 3.91 11\n",
|
||||
"一分钟仰卧起坐 3.86 14\n",
|
||||
"单脚站立 2.32 25\n",
|
||||
"选择反应时 3.72 25\n",
|
||||
"台阶指数 2.18 22\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": "code",
|
||||
"execution_count": null,
|
||||
"id": "272b7618-9a46-4f93-b2b9-e65519cd97c1",
|
||||
"id": "ef75cdd8-d83e-48ab-9867-11102714202a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
|
||||
Reference in new issue
Block a user