20250223
This commit is contained in:
1 parent
adfaa3c638
commit
82acaa07a8
2 files changed
+468
-30
No files matched your search
+440
-2
@@ -3,7 +3,9 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "511a2aee-e09b-475a-a201-f6e1c72e053b",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# 体测数据处理"
|
||||
]
|
||||
@@ -1282,8 +1284,444 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1208eb16-a220-48c4-8c9e-cc4dbf67306e",
|
||||
"id": "8feaa7bb-92dd-44ab-9869-c601d468b4b8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# 体测数据处理(2025年)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "54ed5a3c-ba4d-463f-83f7-3c621142f7bb",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 体测人员导入"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 23,
|
||||
"id": "80a24c3c-8f7d-4c02-a5ee-3daa438ca35b",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:27:26.442760Z",
|
||||
"iopub.status.busy": "2025-01-20T01:27:26.442000Z",
|
||||
"iopub.status.idle": "2025-01-20T01:27:26.468889Z",
|
||||
"shell.execute_reply": "2025-01-20T01:27:26.468324Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:27:26.442687Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"81 ok\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import openpyxl\n",
|
||||
"import json\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"wb = openpyxl.load_workbook('data/青海2025.xlsx')\n",
|
||||
"sheet = wb.active\n",
|
||||
"# sheets = wb.sheetnames\n",
|
||||
"person = {}\n",
|
||||
"\n",
|
||||
"for n in range(2, sheet.max_row+1):\n",
|
||||
" if sheet.cell(n, 1).value is not None:\n",
|
||||
" #print(sheet.cell(n, 1).value)\n",
|
||||
" code = int(sheet.cell(n, 1).value)\n",
|
||||
" person.setdefault(code, {})\n",
|
||||
" dict1 = {}\n",
|
||||
" dict1['name'] = sheet.cell(n, 3).value\n",
|
||||
" dict1['sex'] = sheet.cell(n, 4).value\n",
|
||||
" dict1['unit'] = sheet.cell(n, 2).value\n",
|
||||
" dict1['phone'] = int(sheet.cell(n, 6).value)\n",
|
||||
" dict1['birth'] = str(sheet.cell(n, 5).value).replace('/','-').split(' ')[0]\n",
|
||||
" person[code] = dict1\n",
|
||||
"\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename, 'w') as fl:\n",
|
||||
" json.dump(person, fl, ensure_ascii=False)\n",
|
||||
"print(len(person),'ok')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "90ce631b-0eeb-4d27-965a-7efa09332139",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 获取人员测试成绩"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 16,
|
||||
"id": "905dbd60-ef28-4bf4-85a2-5b2e6543dcfe",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:12:15.444982Z",
|
||||
"iopub.status.busy": "2025-01-20T01:12:15.444234Z",
|
||||
"iopub.status.idle": "2025-01-20T01:12:15.461283Z",
|
||||
"shell.execute_reply": "2025-01-20T01:12:15.460768Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:12:15.444909Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"72\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import datetime\n",
|
||||
"import csv\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"re_ta = {}\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl) \n",
|
||||
"\n",
|
||||
"filename = 'data/marks_20250118.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",
|
||||
"\n",
|
||||
"for result in list1:\n",
|
||||
" user = str(result[2])\n",
|
||||
" rq = date.fromisoformat(result[5].replace('/','-'))\n",
|
||||
" if user in dict1.keys():\n",
|
||||
" l_xm = []\n",
|
||||
" m_item = str(result[3]) \n",
|
||||
" re_ta.setdefault(user,{}) \n",
|
||||
" re_ta[user]['name'] = dict1[user]['name']\n",
|
||||
" re_ta[user]['sex'] = dict1[user]['sex']\n",
|
||||
" if 'phone' in dict1[user].keys():\n",
|
||||
" re_ta[user]['phone'] = dict1[user]['phone']\n",
|
||||
" if dict1[user]['sex'] == '男':\n",
|
||||
" l_xm = ['bmi','lung','grip','flexion','jump','pushup','balance','reaction','step']\n",
|
||||
" else:\n",
|
||||
" l_xm = ['bmi','lung','grip','flexion','jump','balance','reaction','step','situp']\n",
|
||||
" re_ta[user]['unit'] = dict1[user]['unit']\n",
|
||||
" birth = date.fromisoformat(dict1[user]['birth'].replace('/','-'))\n",
|
||||
" item_name = result[3] \n",
|
||||
" if item_name in l_xm: \n",
|
||||
" days = (rq-birth).days \n",
|
||||
" re_ta[user]['age'] = int(days/365)\n",
|
||||
" re_ta[user]['month'] = int(days/365*12)\n",
|
||||
" re_ta[user]['rq'] = result[5]\n",
|
||||
" re_ta[user].setdefault(item_name,{}) \n",
|
||||
" score = result[4] \n",
|
||||
" re_ta[user][item_name]['成绩'] = score\n",
|
||||
"\n",
|
||||
"filename = 'data/result_青海2025.json'\n",
|
||||
"with open(filename,'w') as fl:\n",
|
||||
" json.dump(re_ta, fl, ensure_ascii=False) \n",
|
||||
"print(len(re_ta))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c6ede59a-e5a0-489b-853f-f317e12b1fa3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 导出测试人员信息"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 17,
|
||||
"id": "f3d39079-fa3a-400c-990e-75a8a0a7b42d",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:12:49.821141Z",
|
||||
"iopub.status.busy": "2025-01-20T01:12:49.820394Z",
|
||||
"iopub.status.idle": "2025-01-20T01:12:49.854877Z",
|
||||
"shell.execute_reply": "2025-01-20T01:12:49.854327Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:12:49.821069Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import openpyxl\n",
|
||||
"\n",
|
||||
"items = ['lung','grip','flexion','jump','pushup','situp','balance','reaction','step']\n",
|
||||
"title = ['编号','姓名','性别','单位','身高','体重','肺活量','握力','坐位体前屈','纵跳','俯卧撑','一分钟仰卧起坐','单脚站立','选择反应时','台阶指数']\n",
|
||||
"\n",
|
||||
"filename = 'data/result_青海2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict2 = json.load(fl)\n",
|
||||
" \n",
|
||||
"list1 = []\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" list2 = []\n",
|
||||
" list2.append(str(k).rjust(5,'0'))\n",
|
||||
" list2.append(v['name']) \n",
|
||||
" list2.append(dict2[k]['sex'])\n",
|
||||
" list2.append(dict2[k]['unit'])\n",
|
||||
" if 'bmi' in v.keys():\n",
|
||||
" height = v['bmi']['成绩'].split(',')[0]\n",
|
||||
" weight = v['bmi']['成绩'].split(',')[1]\n",
|
||||
" list2.append(height)\n",
|
||||
" list2.append(weight)\n",
|
||||
" else:\n",
|
||||
" list2.append('')\n",
|
||||
" list2.append('')\n",
|
||||
" for item in items:\n",
|
||||
" if item in v.keys():\n",
|
||||
" list2.append(v[item]['成绩']) \n",
|
||||
" elif item =='name':\n",
|
||||
" list2.append(v[item])\n",
|
||||
" else:\n",
|
||||
" list2.append('')\n",
|
||||
" \n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/青海体测情况表2025.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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a19c9733-7af5-4dc6-a0ca-cc35069f532a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计参加问卷人员"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 25,
|
||||
"id": "f0ee678a-1dd1-4928-a198-df0ff5142f89",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:27:43.425720Z",
|
||||
"iopub.status.busy": "2025-01-20T01:27:43.425142Z",
|
||||
"iopub.status.idle": "2025-01-20T01:27:43.449977Z",
|
||||
"shell.execute_reply": "2025-01-20T01:27:43.449445Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:27:43.425664Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"80\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone1 = set()\n",
|
||||
"phone2 = set()\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" phone1.add(v['phone'])\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20250118.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",
|
||||
" list1.append(line)\n",
|
||||
"print(len(phone1))\n",
|
||||
"i =1\n",
|
||||
"list2 = []\n",
|
||||
"for item in list1:\n",
|
||||
" code = int(item[2])\n",
|
||||
" for k, v in dict1.items():\n",
|
||||
" list3 = []\n",
|
||||
" if v['phone'] == code: \n",
|
||||
" list3.append(k)\n",
|
||||
" list3.append(v['name'])\n",
|
||||
" list3.append(v['sex'])\n",
|
||||
" list3.append(v['unit'])\n",
|
||||
" list3.append(code)\n",
|
||||
" list2.append(list3)\n",
|
||||
"filename = 'data/青海问卷情况表2025.xlsx'\n",
|
||||
"wb = openpyxl.Workbook()\n",
|
||||
"sheet = wb.active\n",
|
||||
"#sheet.append(title)\n",
|
||||
"for row in list2:\n",
|
||||
" sheet.append(row)\n",
|
||||
" \n",
|
||||
"wb.save(filename) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "19aaf610-b15d-45c8-b22e-c56e9b8d8450",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计问卷人员手机号码未登记"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 24,
|
||||
"id": "00eb991d-771f-4ff4-af9f-35a0d3b64581",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-20T01:27:34.074005Z",
|
||||
"iopub.status.busy": "2025-01-20T01:27:34.073295Z",
|
||||
"iopub.status.idle": "2025-01-20T01:27:34.085198Z",
|
||||
"shell.execute_reply": "2025-01-20T01:27:34.084107Z",
|
||||
"shell.execute_reply.started": "2025-01-20T01:27:34.073939Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"80\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone1 = set()\n",
|
||||
"phone2 = set()\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" phone1.add(v['phone'])\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20250118.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",
|
||||
" list1.append(line)\n",
|
||||
"print(len(phone1))\n",
|
||||
"i =1\n",
|
||||
"list2 = []\n",
|
||||
"for item in list1:\n",
|
||||
" code = int(item[2])\n",
|
||||
" if code not in phone1:\n",
|
||||
" content = json.loads(item[5])\n",
|
||||
" if 'name' in content.keys():\n",
|
||||
" print(code,content['name'])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9cabe52a-2862-4ba8-847f-d685df1060cd",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## 统计未参加问卷人员"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "d91e74d4-22f0-4db2-bad4-717f7537c043",
|
||||
"metadata": {
|
||||
"execution": {
|
||||
"iopub.execute_input": "2025-01-22T05:32:09.347446Z",
|
||||
"iopub.status.busy": "2025-01-22T05:32:09.346691Z",
|
||||
"iopub.status.idle": "2025-01-22T05:32:09.373252Z",
|
||||
"shell.execute_reply": "2025-01-22T05:32:09.372574Z",
|
||||
"shell.execute_reply.started": "2025-01-22T05:32:09.347377Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"45\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import json\n",
|
||||
"import csv\n",
|
||||
"import openpyxl\n",
|
||||
"import time\n",
|
||||
"from datetime import date\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"filename = 'data/青海人员2025.json'\n",
|
||||
"with open(filename,'r') as fl:\n",
|
||||
" dict1 = json.load(fl)\n",
|
||||
"\n",
|
||||
"phone1 = set()\n",
|
||||
"phone2 = set()\n",
|
||||
"for k,v in dict1.items():\n",
|
||||
" phone1.add(v['phone'])\n",
|
||||
"list1 = []\n",
|
||||
"filename = 'data/Survey_20250118.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",
|
||||
" phone2.add(int(line[2]))\n",
|
||||
"print(len(phone2))\n",
|
||||
"i =1\n",
|
||||
"\n",
|
||||
"for k, v in dict1.items():\n",
|
||||
" if v['phone'] not in phone2:\n",
|
||||
" list2 = []\n",
|
||||
" list2 = [k,v['name'],v['sex'],v['phone']]\n",
|
||||
" list1.append(list2)\n",
|
||||
"filename = 'data/青海未参加问卷人员2025.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) "
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "1208eb16-a220-48c4-8c9e-cc4dbf67306e",
|
||||
"metadata": {
|
||||
"jp-MarkdownHeadingCollapsed": true
|
||||
},
|
||||
"source": [
|
||||
"# 体测数据分析"
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user