This commit is contained in:
512song committed 2023-03-23 15:11:08 +00:00
1 parent 1000a8f2ea
commit d30e4b0ca7
2 files changed
+509 -64

No files matched your search

+336 -64
View File
@@ -432,22 +432,12 @@
"cell_type": "markdown",
"id": "bb3448ff-a8d3-417d-ab3a-4b54e28aaca0",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": [],
"toc-hr-collapsed": true
"tags": []
},
"source": [
"## 2023年体测情况"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e7af531-758b-477b-a181-21080c83b44c",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "d7ad01ef-93c3-4735-b609-bb5d38f85a25",
@@ -470,6 +460,7 @@
"import json\n",
"import pymysql\n",
"\n",
"\n",
"fi_xls = 'data/低碳院多点账号20230217.xlsx'\n",
"chongming = ['王锐','王楠','郭强','王涛','张静']\n",
"dict1 = {}\n",
@@ -501,8 +492,335 @@
},
{
"cell_type": "markdown",
"id": "c27c6f4b-d0ed-40e8-aed9-09662edd21c6",
"id": "f1d79414-577e-4bfa-b3db-1c9ac3168f76",
"metadata": {},
"source": [
"### 获取人员统计信息"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "916e4437-d28a-4d41-ab87-9470c6b7116d",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"import pymysql\n",
"import datetime\n",
"\n",
"dict1 = {}\n",
"dict2 = {}\n",
"dict3 = {}\n",
"\n",
"db = pymysql.connect(host = \"localhost\",user = \"songyi\",password = \"yylzs\",database = \"ydyb\" )\n",
"cursor = db.cursor()\n",
"sql = \"SELECT b.avatar_id, a.name ,a.sex,a.birth FROM people as a,places_people as b WHERE a.id =b.people_id AND b.place_id = 139\"\n",
"cursor.execute(sql)\n",
"results = cursor.fetchall()\n",
"for result in results:\n",
" bh = result[0]\n",
" \n",
" name = str(result[1]).strip()\n",
" dict2.setdefault(bh,{})\n",
" dict2[bh]['name'] = name\n",
" dict2[bh]['sex'] = result[2]\n",
" #dict2[bh]['birth'] = result[3]\n",
" #print(result[3])\n",
" days = (datetime.date(2023, 3, 6)-result[3]).days\n",
" dict2[bh]['age'] = round(days/365)\n",
"\n",
"filename = 'data/低碳院体测人员信息2023.json'\n",
"with open(filename, 'w') as fl:\n",
" json.dump(dict2, fl, ensure_ascii=False)\n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "e659cc7e-080a-4ad6-9306-3cfff0aca134",
"metadata": {},
"source": [
"### 获取人员测试成绩"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e6b4c99-fa09-414d-9dd5-932835d8609c",
"metadata": {
"tags": []
},
"outputs": [],
"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",
"#SQL语句为:\n",
"#SELECT a.item_id,a.performance,a.score,a.date AS DATE1,a.avatar_id,b.unit,b.name,a.date_joined FROM places_result AS a,_tianjin AS b WHERE a.place_id=134 AND a.avatar_id=b.id\n",
"\n",
"re_ta = {}\n",
"dict1 = {}\n",
"list1 = []\n",
"#print(\"\\n运动项目信息:\")\n",
"filename = 'data/139.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[4])\n",
" m_item = str(result[0]) \n",
" re_ta.setdefault(user,{}) \n",
" re_ta[user]['name'] = str(result[6])\n",
" re_ta[user]['unit'] = str(result[5]) \n",
" item_name = item[m_item]['name']\n",
" re_ta[user].setdefault(item_name,{}) \n",
" score = int(result[1])/item[m_item]['divisor'] \n",
" re_ta[user][item_name]['成绩'] = f'{score} {item[m_item][\"unit\"]}'\n",
" re_ta[user][item_name]['得分'] =result[2]\n",
"filename = 'data/result_低碳院.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(re_ta, fl) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "36085f28-fad2-490e-b085-2ef5dd5d64c8",
"metadata": {},
"source": [
"### 统计人员测试成绩"
]
},
{
"cell_type": "markdown",
"id": "9e0f798b-665f-4ffb-a18c-fc8f87f21ade",
"metadata": {},
"source": [
"#### 汇总人员信息及成绩"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "18b7ab77-8fc3-4edf-93c4-9a1e29cd71f6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import json\n",
"\n",
"\n",
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_低碳院.json'\n",
"\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"\n",
"filename = 'data/低碳院体测人员信息2023.json'\n",
"with open(filename,'r') as fl:\n",
" dict2 = json.load(fl) \n",
"for k,v in dict1.items():\n",
" print(k)\n",
" score = 0\n",
" i = 0\n",
" for k1,v1 in v.items():\n",
" \n",
" \n",
" if k1 in items:\n",
" score = score + int(v1['得分'])\n",
" i+=1\n",
" \n",
" dict1[k]['age'] = dict2[k]['age']\n",
" dict1[k]['sex'] = dict2[k]['sex']\n",
" dict1[k]['score'] = round(score/i,2)\n",
" \n",
"filename = 'data/result_低碳院.json'\n",
"with open(filename,'w') as fl:\n",
" json.dump(dict1, fl) \n",
"print('ok')"
]
},
{
"cell_type": "markdown",
"id": "8c97bf0f-2b01-487d-bd18-200fcbe2c9b3",
"metadata": {},
"source": [
"#### 根据年龄汇总人员信息及成绩"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "bcc60f36-71aa-4d59-b4dd-55b1f95ef4f3",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-23T13:10:46.922922Z",
"iopub.status.busy": "2023-03-23T13:10:46.922072Z",
"iopub.status.idle": "2023-03-23T13:10:46.938257Z",
"shell.execute_reply": "2023-03-23T13:10:46.937054Z",
"shell.execute_reply.started": "2023-03-23T13:10:46.922881Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"20~24岁平均成绩:1.82分,人数:2人\n",
"25~29岁平均成绩:3.0分,人数:13人\n",
"30~34岁平均成绩:3.01分,人数:36人\n",
"35~39岁平均成绩:3.23分,人数:41人\n",
"40~44岁平均成绩:3.05分,人数:55人\n",
"45~49岁平均成绩:2.82分,人数:14人\n",
"50~54岁平均成绩:2.88分,人数:5人\n",
"55~59岁平均成绩:2.14分,人数:5人\n",
"60~69岁平均成绩:1.45分,人数:1人\n"
]
}
],
"source": [
"import json\n",
"\n",
"\n",
"nld = [[20,24],[25,29],[30,34],[35,39],[40,44],[45,49],[50,54],[55,59],[60,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",
" for k,v in dict1.items():\n",
" if v['age'] in range(di,gao+1):\n",
" score = score+v['score']\n",
" i+=1\n",
" print(f'{di}~{gao}岁平均成绩:{round(score/i,2)}分,人数:{i-1}人')\n",
"\n"
]
},
{
"cell_type": "markdown",
"id": "f0d65f4e-04e8-4680-9b30-77b045be4e0a",
"metadata": {},
"source": [
"#### 根据项目汇总人员信息及成绩"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "f0624326-7a21-4358-a036-daf03432bc80",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-23T13:46:30.165738Z",
"iopub.status.busy": "2023-03-23T13:46:30.164841Z",
"iopub.status.idle": "2023-03-23T13:46:30.207376Z",
"shell.execute_reply": "2023-03-23T13:46:30.206332Z",
"shell.execute_reply.started": "2023-03-23T13:46:30.165698Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'体重': {'总体': [625, 165], '男': [310, 94], '女': [315, 71]}, '肺活量': {'总体': [651, 166], '男': [371, 95], '女': [280, 71]}, '握力': {'总体': [335, 159], '男': [191, 93], '女': [144, 66]}, '坐位体前屈': {'总体': [474, 162], '男': [248, 92], '女': [226, 70]}, '纵跳': {'总体': [515, 164], '男': [276, 94], '女': [239, 70]}, '俯卧撑': {'总体': [322, 85], '男': [322, 85]}, '一分钟仰卧起坐': {'总体': [246, 59], '女': [246, 59]}, '单脚站立': {'总体': [339, 165], '男': [169, 94], '女': [170, 71]}, '选择反应时': {'总体': [562, 164], '男': [313, 93], '女': [249, 71]}, '台阶指数': {'总体': [413, 146], '男': [239, 84], '女': [174, 62]}}\n"
]
}
],
"source": [
"import json\n",
"import openpyxl\n",
"\n",
"items = ['体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
"filename = 'data/result_低碳院.json'\n",
"with open(filename,'r') as fl:\n",
" dict1 = json.load(fl) \n",
"dict2 = {}\n",
"for item in items:\n",
" dict2.setdefault(item,{})\n",
" for k, v in dict1.items():\n",
" if item in v.keys():\n",
" dict2[item].setdefault('总体',[0,0])\n",
" \n",
" if v['sex']==0:\n",
" sex = '男'\n",
" else:\n",
" sex = '女'\n",
" dict2[item].setdefault(sex,[0,0])\n",
" dict2[item]['总体'][0]= dict2[item]['总体'][0]+int(v[item]['得分'])\n",
" dict2[item]['总体'][1]= dict2[item]['总体'][1]+1\n",
" dict2[item][sex][0] = dict2[item][sex][0]+int(v[item]['得分'])\n",
" dict2[item][sex][1] = dict2[item][sex][1]+1\n",
"print(dict2)\n",
"title= []\n",
"zt= []\n",
"nan= []\n",
"nv = []\n",
"title.append('')\n",
"zt.append('总体')\n",
"nan.append('男性')\n",
"nv.append('女性')\n",
"for k, v in dict2.items():\n",
" title.append(k)\n",
" zt.append(round(v['总体'][0]/v['总体'][1],2))\n",
" if '男' in v.keys():\n",
" nan.append(round(v['男'][0]/v['男'][1],2))\n",
" else:\n",
" nan.append(' ')\n",
" if '女' in v.keys():\n",
" nv.append(round(v['女'][0]/v['女'][1],2))\n",
" else:\n",
" nv.append(' ')\n",
"list1 = []\n",
"\n",
"list1.append(zt)\n",
"list1.append(nan)\n",
"list1.append(nv)\n",
"filename = 'data/低碳院不同性别成绩分析.xlsx'\n",
"wb = openpyxl.Workbook()\n",
"sheet = wb.active\n",
"sheet.append(title)\n",
"for row in list1:\n",
" sheet.append(row)\n",
" \n",
"wb.save(filename)\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n"
]
},
{
"cell_type": "markdown",
"id": "c27c6f4b-d0ed-40e8-aed9-09662edd21c6",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"### 统计问卷人员信息"
]
@@ -1352,16 +1670,9 @@
},
{
"cell_type": "code",
"execution_count": 65,
"execution_count": null,
"id": "162e0573-e1c7-4538-bffa-c34eb5b40d8a",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-22T12:47:26.571739Z",
"iopub.status.busy": "2023-03-22T12:47:26.570902Z",
"iopub.status.idle": "2023-03-22T12:47:26.591504Z",
"shell.execute_reply": "2023-03-22T12:47:26.590497Z",
"shell.execute_reply.started": "2023-03-22T12:47:26.571699Z"
},
"tags": []
},
"outputs": [],
@@ -1403,27 +1714,12 @@
},
{
"cell_type": "code",
"execution_count": 68,
"execution_count": null,
"id": "b48f9fba-d8e9-4d47-a456-48065a912f5f",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-22T12:51:48.070188Z",
"iopub.status.busy": "2023-03-22T12:51:48.069351Z",
"iopub.status.idle": "2023-03-22T12:51:48.091373Z",
"shell.execute_reply": "2023-03-22T12:51:48.090459Z",
"shell.execute_reply.started": "2023-03-22T12:51:48.070146Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import os\n",
@@ -1517,29 +1813,12 @@
},
{
"cell_type": "code",
"execution_count": 74,
"execution_count": null,
"id": "204fcae8-32e6-4016-b533-b8a8a750580e",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-22T13:00:02.518291Z",
"iopub.status.busy": "2023-03-22T13:00:02.517403Z",
"iopub.status.idle": "2023-03-22T13:00:02.560955Z",
"shell.execute_reply": "2023-03-22T13:00:02.559935Z",
"shell.execute_reply.started": "2023-03-22T13:00:02.518251Z"
},
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"113\n",
"[['适应A组', '宗瑾', 0], ['适应A组', '范玉建', 0], ['适应A组', '小新卖蜡笔💚', 1], ['适应A组', '李轩', 1], ['适应A组', '赵文静', 1], ['适应A组', '啦啦啦', 2], ['适应A组', '沐风', 3], ['适应A组', '杨征', 4], ['适应A组', '毛毛李', 4], ['适应A组', 'Hansolo', 4], ['适应A组', '李旭影', 5], ['适应A组', '林泉', 5], ['适应A组', '海', 5], ['适应A组', '阮如玉', 7], ['适应A组', 'Qieyingli', 7], ['适应A组', '赵璐璐', 8], ['适应A组', '王绍亮', 9], ['适应A组', '冰王子', 10], ['适应A组', '贾小胖', 11], ['适应A组', 'yuandelin', 13], ['适应A组', '于双恩', 14], ['适应A组', '红太虎', 14], ['适应A组', '杨如意', 20], ['适应A组', 'Fan Yongsheng', 22], ['适应A组', '晓亚', 25], ['适应A组', 'Lan💐💐💐', 25], ['适应A组', '贺国锋', 28], ['适应A组', '闫瑞军', 29], ['适应A组', '呆呆(丹)🍀', 29], ['适应A组', '齐云龙', 35], ['适应A组', '高星', 42], ['适应A组', '高高兴兴', 43], ['适应A组', '孙任晖', 48], ['适应A组', '王海棠', 50], ['适应A组', '顺其自然', 73], ['适应A组', '老罗', 75], ['适应A组', 'Ssss', 77], ['适应A组', '阿白', 79], ['适应A组', 'Linge', 88], ['适应A组', '董春伟', 94], ['适应A组', 'LyuYJ', 95], ['适应A组', '阿杜', 71], ['适应B组', '宗瑾', 0], ['适应B组', '王涛', 0], ['适应B组', '张凡', 1], ['适应B组', '浩', 2], ['适应B组', '葱', 3], ['适应B组', '程萌', 3], ['适应B组', '无', 6], ['适应B组', 'Shuai', 22], ['适应B组', '。。。', 23], ['适应B组', '韩志华', 25], ['适应B组', '龙龙', 39], ['适应B组', 'YX~', 44], ['适应B组', 'liqiands', 45], ['适应B组', '比小熊', 57], ['适应B组', '欢欢', 63], ['适应B组', 'scofiedys', 64], ['适应B组', '武月', 103], ['适应C组', '宗瑾', 0], ['适应C组', '胜录', 0], ['适应C组', 'candy', 0], ['适应C组', '阳光雨露', 1], ['适应C组', '劉知邦', 1], ['适应C组', '方秋', 1], ['适应C组', '赵华博', 2], ['适应C组', '时㈥🇨🇳', 3], ['适应C组', '赛赛\\ue305', 8], ['适应C组', '延鑫', 9], ['适应C组', '颜', 12], ['适应C组', '韦慧🎈', 12], ['适应C组', '许明', 23], ['适应C组', '康善娇', 25], ['适应C组', '王伟', 30], ['适应C组', '丁江涛', 31], ['适应C组', '城墙', 51], ['适应C组', '香龙', 53], ['适应C组', '🍜李为真', 54], ['适应C组', 'Ming', 57], ['适应C组', '王子鑫', 73], ['适应C组', 'Ophelia琪', 82], ['适应C组', '张寅灵', 82], ['适应C组', '张艳杰', 107], ['提高组', '宗瑾', 0], ['提高组', '小新卖蜡笔💚', 0], ['提高组', 'momo', 1], ['提高组', 'momo', 15], ['提高组', '郭建秋', 17], ['提高组', 'fumei🍭🍿', 62], ['提高组', '刘捷', 89], ['提高组', '赵明', 89]]\n",
"ok\n"
]
}
],
"outputs": [],
"source": [
"import json\n",
"import time\n",
@@ -1589,16 +1868,9 @@
},
{
"cell_type": "code",
"execution_count": 76,
"execution_count": null,
"id": "c12b2d1b-774e-40c1-8a80-df3fa5889b61",
"metadata": {
"execution": {
"iopub.execute_input": "2023-03-22T13:11:58.767063Z",
"iopub.status.busy": "2023-03-22T13:11:58.766209Z",
"iopub.status.idle": "2023-03-22T13:11:58.852385Z",
"shell.execute_reply": "2023-03-22T13:11:58.851586Z",
"shell.execute_reply.started": "2023-03-22T13:11:58.767021Z"
},
"tags": []
},
"outputs": [],