20230114
This commit is contained in:
1 parent
64d8cd5e16
commit
e9356da639
1 file changed
+304
-102
+304
-102
@@ -830,27 +830,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 151,
|
"execution_count": null,
|
||||||
"id": "6e6f6a63-b297-42e8-a9ba-b2636fda5d09",
|
"id": "6e6f6a63-b297-42e8-a9ba-b2636fda5d09",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-14T01:56:50.048701Z",
|
|
||||||
"iopub.status.busy": "2023-01-14T01:56:50.047669Z",
|
|
||||||
"iopub.status.idle": "2023-01-14T01:56:50.449993Z",
|
|
||||||
"shell.execute_reply": "2023-01-14T01:56:50.448696Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-14T01:56:50.048628Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
@@ -878,27 +863,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 149,
|
"execution_count": null,
|
||||||
"id": "4d77ec9b-c561-4355-98af-b18c42c1f3ca",
|
"id": "4d77ec9b-c561-4355-98af-b18c42c1f3ca",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-14T01:56:10.352541Z",
|
|
||||||
"iopub.status.busy": "2023-01-14T01:56:10.352010Z",
|
|
||||||
"iopub.status.idle": "2023-01-14T01:56:13.111656Z",
|
|
||||||
"shell.execute_reply": "2023-01-14T01:56:13.110214Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-14T01:56:10.352494Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
"import json\n",
|
"import json\n",
|
||||||
@@ -941,27 +911,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 150,
|
"execution_count": null,
|
||||||
"id": "db473c01-7e1a-48c4-a0d7-e44cdeb9e24b",
|
"id": "db473c01-7e1a-48c4-a0d7-e44cdeb9e24b",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-14T01:56:24.524792Z",
|
|
||||||
"iopub.status.busy": "2023-01-14T01:56:24.524267Z",
|
|
||||||
"iopub.status.idle": "2023-01-14T01:56:24.967568Z",
|
|
||||||
"shell.execute_reply": "2023-01-14T01:56:24.966212Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-14T01:56:24.524745Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"import openpyxl\n",
|
"import openpyxl\n",
|
||||||
@@ -996,27 +951,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 152,
|
"execution_count": null,
|
||||||
"id": "224cdee4-153f-424a-aaaa-92ef58943edb",
|
"id": "224cdee4-153f-424a-aaaa-92ef58943edb",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
|
||||||
"iopub.execute_input": "2023-01-14T01:56:53.363160Z",
|
|
||||||
"iopub.status.busy": "2023-01-14T01:56:53.362570Z",
|
|
||||||
"iopub.status.idle": "2023-01-14T01:56:53.912576Z",
|
|
||||||
"shell.execute_reply": "2023-01-14T01:56:53.911169Z",
|
|
||||||
"shell.execute_reply.started": "2023-01-14T01:56:53.363112Z"
|
|
||||||
},
|
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"ok\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"import json\n",
|
"import json\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -1042,6 +982,14 @@
|
|||||||
" dict3[k]['score'] = score\n",
|
" dict3[k]['score'] = score\n",
|
||||||
" dict3[k]['item_num'] = i\n",
|
" dict3[k]['item_num'] = i\n",
|
||||||
" dict3[k]['avg'] = round(score/i,2)\n",
|
" dict3[k]['avg'] = round(score/i,2)\n",
|
||||||
|
"filename = 'data/天津石化线上测试结果.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" if k in dict1.keys():\n",
|
||||||
|
" dict3[k] = dict2[k]\n",
|
||||||
|
" dict3[k]['zhongyi'] = dict1[k]['中医体质']\n",
|
||||||
|
" \n",
|
||||||
"filename = 'data/天津石化人员231113_1.json'\n",
|
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||||
"with open(filename, 'w') as fl:\n",
|
"with open(filename, 'w') as fl:\n",
|
||||||
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
" json.dump(dict3, fl, ensure_ascii=False)\n",
|
||||||
@@ -1066,15 +1014,264 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 168,
|
"execution_count": null,
|
||||||
"id": "2a964412-8408-4039-a788-8cc1fc7cd518",
|
"id": "2a964412-8408-4039-a788-8cc1fc7cd518",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"unit = set()\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" unit.add(dict1[k]['unit'])\n",
|
||||||
|
"#print(unit)\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" dict2.setdefault(v['unit'],{})\n",
|
||||||
|
" dict2[v['unit']].setdefault('是',{})\n",
|
||||||
|
" dict2[v['unit']].setdefault('否',{})\n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('num',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('num',0)\n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('score',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('score',0)\n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('zhongyi',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('zhongyi',0) \n",
|
||||||
|
" dict2[v['unit']]['是'].setdefault('pianpo',0)\n",
|
||||||
|
" dict2[v['unit']]['否'].setdefault('pianpo',0) \n",
|
||||||
|
" if 'avg' in v.keys():\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['num'] = dict2[v['unit']][v['daoban']]['num'] + 1\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['score'] = dict2[v['unit']][v['daoban']]['score'] + v['avg']\n",
|
||||||
|
" if 'zhongyi' in v.keys() :\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['zhongyi'] = dict2[v['unit']][v['daoban']]['zhongyi'] + 1\n",
|
||||||
|
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||||||
|
" dict2[v['unit']][v['daoban']]['pianpo'] = dict2[v['unit']][v['daoban']]['pianpo'] + 1\n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
"for k, v in dict2.items(): \n",
|
||||||
|
" if v['是']['num'] > 0:\n",
|
||||||
|
" dict2[k]['是']['avg'] = round(v['是']['score']/v['是']['num'],2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict2[k]['是']['avg'] = 0\n",
|
||||||
|
" if v['否']['num'] > 0:\n",
|
||||||
|
" dict2[k]['否']['avg'] = round(v['否']['score']/v['否']['num'],2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" dict2[k]['否']['avg'] = 0\n",
|
||||||
|
"list1 = [] \n",
|
||||||
|
"for k, v in dict2.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" unit = k\n",
|
||||||
|
" for k1, v1 in v.items():\n",
|
||||||
|
" daoban = k1\n",
|
||||||
|
" num = v1['num']\n",
|
||||||
|
" avg = v1['avg']\n",
|
||||||
|
" zhongyi = v1['zhongyi']\n",
|
||||||
|
" pianpo = v1['pianpo']\n",
|
||||||
|
" list2 = [k,daoban,num,avg,zhongyi,pianpo]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
" \n",
|
||||||
|
"filename = 'data/天津倒班因素分析表.xlsx' \n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)\n",
|
||||||
|
"print('ok!')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "2ccc4f6c-9cde-42d5-b41d-5b35ad86f042",
|
||||||
|
"metadata": {
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"#### 工龄因素分析"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 183,
|
||||||
|
"id": "695b4933-b8c3-4be6-a024-742a982f0abb",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"execution": {
|
"execution": {
|
||||||
"iopub.execute_input": "2023-01-14T03:54:06.706899Z",
|
"iopub.execute_input": "2023-01-14T08:57:36.572541Z",
|
||||||
"iopub.status.busy": "2023-01-14T03:54:06.706358Z",
|
"iopub.status.busy": "2023-01-14T08:57:36.571983Z",
|
||||||
"iopub.status.idle": "2023-01-14T03:54:06.815555Z",
|
"iopub.status.idle": "2023-01-14T08:57:36.671348Z",
|
||||||
"shell.execute_reply": "2023-01-14T03:54:06.814512Z",
|
"shell.execute_reply": "2023-01-14T08:57:36.670273Z",
|
||||||
"shell.execute_reply.started": "2023-01-14T03:54:06.706851Z"
|
"shell.execute_reply.started": "2023-01-14T08:57:36.572493Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"{2: {'男': {'num': 700, 'score': 1913.639999999998, 'zhongyi': 91, 'pianpo': 73}, '女': {'num': 550, 'score': 1736.5499999999988, 'zhongyi': 47, 'pianpo': 43}}, 1: {'男': {'num': 465, 'score': 1291.3899999999994, 'zhongyi': 153, 'pianpo': 119}, '女': {'num': 265, 'score': 846.3700000000005, 'zhongyi': 47, 'pianpo': 45}}, 3: {'男': {'num': 1161, 'score': 3063.0399999999995, 'zhongyi': 144, 'pianpo': 109}, '女': {'num': 279, 'score': 865.81, 'zhongyi': 39, 'pianpo': 34}}, 4: {'男': {'num': 163, 'score': 406.15000000000003, 'zhongyi': 23, 'pianpo': 19}}, 0: {'女': {'num': 405, 'score': 1218.0100000000002, 'zhongyi': 40, 'pianpo': 27}, '男': {'num': 737, 'score': 1971.2600000000007, 'zhongyi': 87, 'pianpo': 44}}, 5: {'男': {'num': 1, 'score': 2.57, 'zhongyi': 0, 'pianpo': 0}}}\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"unit = set()\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" unit.add(dict1[k]['unit'])\n",
|
||||||
|
"#print(unit)\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" gld = int(int(v['gl'])/10)\n",
|
||||||
|
" dict2.setdefault(gld,{})\n",
|
||||||
|
" dict2[gld].setdefault(v['sex'],{})\n",
|
||||||
|
" dict2[gld][v['sex']].setdefault('num',0)\n",
|
||||||
|
" dict2[gld][v['sex']].setdefault('score',0)\n",
|
||||||
|
" dict2[gld][v['sex']].setdefault('zhongyi',0)\n",
|
||||||
|
" dict2[gld][v['sex']].setdefault('pianpo',0) \n",
|
||||||
|
" if 'avg' in v.keys():\n",
|
||||||
|
" dict2[gld][v['sex']]['num'] = dict2[gld][v['sex']]['num'] + 1\n",
|
||||||
|
" dict2[gld][v['sex']]['score'] = dict2[gld][v['sex']]['score'] + v['avg']\n",
|
||||||
|
" if 'zhongyi' in v.keys() :\n",
|
||||||
|
" dict2[gld][v['sex']]['zhongyi'] = dict2[gld][v['sex']]['zhongyi'] + 1\n",
|
||||||
|
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||||||
|
" dict2[gld][v['sex']]['pianpo'] = dict2[gld][v['sex']]['pianpo'] + 1\n",
|
||||||
|
"nl = {}\n",
|
||||||
|
"nl[0] = '工龄0-9年'\n",
|
||||||
|
"nl[1] = '工龄10-19年'\n",
|
||||||
|
"nl[2] = '工龄20-29年'\n",
|
||||||
|
"nl[3] = '工龄30-39年'\n",
|
||||||
|
"nl[4] = '工龄40-49年'\n",
|
||||||
|
"nl[5] = '工龄50年以上'\n",
|
||||||
|
"list1 = [] \n",
|
||||||
|
"for k, v in nl.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" gld = v\n",
|
||||||
|
" for k1, v1 in dict2[k].items():\n",
|
||||||
|
" num = v1['num']\n",
|
||||||
|
" score = v1['score']\n",
|
||||||
|
" zhongyi = v1['zhongyi']\n",
|
||||||
|
" pianpo = v1['pianpo']\n",
|
||||||
|
" list2 = [k,daoban,num,avg,zhongyi,pianpo]\n",
|
||||||
|
" list1.append(list2)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 188,
|
||||||
|
"id": "181ff60b-3372-441a-8cd7-29e8de66ceb8",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T09:14:36.031368Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T09:14:36.030813Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T09:14:36.136340Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T09:14:36.135039Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T09:14:36.031320Z"
|
||||||
|
},
|
||||||
|
"tags": []
|
||||||
|
},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"{2: {'num': 1250, 'score': 3650.189999999998, 'zhongyi': 138, 'pianpo': 116}, 1: {'num': 730, 'score': 2137.7599999999993, 'zhongyi': 200, 'pianpo': 164}, 3: {'num': 1440, 'score': 3928.850000000005, 'zhongyi': 183, 'pianpo': 143}, 4: {'num': 163, 'score': 406.15000000000003, 'zhongyi': 23, 'pianpo': 19}, 0: {'num': 1142, 'score': 3189.270000000001, 'zhongyi': 127, 'pianpo': 71}, 5: {'num': 1, 'score': 2.57, 'zhongyi': 0, 'pianpo': 0}}\n",
|
||||||
|
"ok!\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import json\n",
|
||||||
|
"import openpyxl\n",
|
||||||
|
"\n",
|
||||||
|
"filename = 'data/天津石化人员231113_1.json'\n",
|
||||||
|
"with open(filename,'r') as fl:\n",
|
||||||
|
" dict1 = json.load(fl)\n",
|
||||||
|
"unit = set()\n",
|
||||||
|
"\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" unit.add(dict1[k]['unit'])\n",
|
||||||
|
"#print(unit)\n",
|
||||||
|
"dict2 = {}\n",
|
||||||
|
"for k, v in dict1.items():\n",
|
||||||
|
" gld = int(int(v['gl'])/10)\n",
|
||||||
|
" dict2.setdefault(gld,{}) \n",
|
||||||
|
" dict2[gld].setdefault('num',0)\n",
|
||||||
|
" dict2[gld].setdefault('score',0)\n",
|
||||||
|
" dict2[gld].setdefault('zhongyi',0)\n",
|
||||||
|
" dict2[gld].setdefault('pianpo',0) \n",
|
||||||
|
" if 'avg' in v.keys():\n",
|
||||||
|
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||||||
|
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||||||
|
" if 'zhongyi' in v.keys() :\n",
|
||||||
|
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||||||
|
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||||||
|
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||||||
|
"print(dict2)\n",
|
||||||
|
"nl = {}\n",
|
||||||
|
"nl[0] = '工龄0-9年'\n",
|
||||||
|
"nl[1] = '工龄10-19年'\n",
|
||||||
|
"nl[2] = '工龄20-29年'\n",
|
||||||
|
"nl[3] = '工龄30-39年'\n",
|
||||||
|
"nl[4] = '工龄40-49年'\n",
|
||||||
|
"nl[5] = '工龄50年以上'\n",
|
||||||
|
"list1 = [] \n",
|
||||||
|
"for k, v in nl.items():\n",
|
||||||
|
" list2 = []\n",
|
||||||
|
" gld = v\n",
|
||||||
|
" \n",
|
||||||
|
" num = dict2[k]['num']\n",
|
||||||
|
" score = dict2[k]['score']\n",
|
||||||
|
" if num > 0:\n",
|
||||||
|
" avg = round(score/num,2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" avg = 0\n",
|
||||||
|
" zhongyi = dict2[k]['zhongyi']\n",
|
||||||
|
" pianpo = dict2[k]['pianpo']\n",
|
||||||
|
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/天津倒班因素分析表(工龄).xlsx' \n",
|
||||||
|
"wb = openpyxl.Workbook()\n",
|
||||||
|
"sheet = wb.active\n",
|
||||||
|
"\n",
|
||||||
|
"for row in list1:\n",
|
||||||
|
" sheet.append(row)\n",
|
||||||
|
" \n",
|
||||||
|
"wb.save(filename)\n",
|
||||||
|
"print('ok!')"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "f8fa3027-c88a-43a1-88c8-c6e9b7e94f91",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"#### 年龄因素分析"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 192,
|
||||||
|
"id": "d5ab1a99-cb3e-4905-8c05-a6122ea09913",
|
||||||
|
"metadata": {
|
||||||
|
"execution": {
|
||||||
|
"iopub.execute_input": "2023-01-14T09:22:28.467869Z",
|
||||||
|
"iopub.status.busy": "2023-01-14T09:22:28.467341Z",
|
||||||
|
"iopub.status.idle": "2023-01-14T09:22:28.568909Z",
|
||||||
|
"shell.execute_reply": "2023-01-14T09:22:28.567550Z",
|
||||||
|
"shell.execute_reply.started": "2023-01-14T09:22:28.467822Z"
|
||||||
},
|
},
|
||||||
"tags": []
|
"tags": []
|
||||||
},
|
},
|
||||||
@@ -1101,37 +1298,42 @@
|
|||||||
"#print(unit)\n",
|
"#print(unit)\n",
|
||||||
"dict2 = {}\n",
|
"dict2 = {}\n",
|
||||||
"for k, v in dict1.items():\n",
|
"for k, v in dict1.items():\n",
|
||||||
" dict2.setdefault(v['unit'],{})\n",
|
" gld = int(int(v['age'])/10)\n",
|
||||||
" dict2[v['unit']].setdefault('是',{})\n",
|
" dict2.setdefault(gld,{}) \n",
|
||||||
" dict2[v['unit']].setdefault('否',{})\n",
|
" dict2[gld].setdefault('num',0)\n",
|
||||||
" dict2[v['unit']]['是'].setdefault('num',0)\n",
|
" dict2[gld].setdefault('score',0)\n",
|
||||||
" dict2[v['unit']]['否'].setdefault('num',0)\n",
|
" dict2[gld].setdefault('zhongyi',0)\n",
|
||||||
" dict2[v['unit']]['是'].setdefault('score',0)\n",
|
" dict2[gld].setdefault('pianpo',0) \n",
|
||||||
" dict2[v['unit']]['否'].setdefault('score',0)\n",
|
" if 'avg' in v.keys():\n",
|
||||||
" dict2[v['unit']][v['daoban']]['num'] = dict2[v['unit']][v['daoban']]['num'] + 1\n",
|
" dict2[gld]['num'] = dict2[gld]['num'] + 1\n",
|
||||||
" dict2[v['unit']][v['daoban']]['score'] = dict2[v['unit']][v['daoban']]['score'] + v['avg']\n",
|
" dict2[gld]['score'] = dict2[gld]['score'] + v['avg']\n",
|
||||||
"for k, v in dict2.items():\n",
|
" if 'zhongyi' in v.keys() :\n",
|
||||||
|
" dict2[gld]['zhongyi'] = dict2[gld]['zhongyi'] + 1\n",
|
||||||
|
" if 'zhongyi' in v.keys() and v['zhongyi']!='平和':\n",
|
||||||
|
" dict2[gld]['pianpo'] = dict2[gld]['pianpo'] + 1\n",
|
||||||
|
"nl = {}\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if v['是']['num'] > 0:\n",
|
"nl[2] = '20-29岁'\n",
|
||||||
" dict2[k]['是']['avg'] = round(v['是']['score']/v['是']['num'],2)\n",
|
"nl[3] = '30-39岁'\n",
|
||||||
" else:\n",
|
"nl[4] = '40-49岁'\n",
|
||||||
" dict2[k]['是']['avg'] = 0\n",
|
"nl[5] = '50-59岁'\n",
|
||||||
" if v['否']['num'] > 0:\n",
|
"nl[6] = '60岁及以上'\n",
|
||||||
" dict2[k]['否']['avg'] = round(v['否']['score']/v['否']['num'],2)\n",
|
|
||||||
" else:\n",
|
|
||||||
" dict2[k]['否']['avg'] = 0\n",
|
|
||||||
"list1 = [] \n",
|
"list1 = [] \n",
|
||||||
"for k, v in dict2.items():\n",
|
"for k, v in nl.items():\n",
|
||||||
" list2 = []\n",
|
" list2 = []\n",
|
||||||
" unit = k\n",
|
" gld = v\n",
|
||||||
" for k1, v1 in v.items():\n",
|
|
||||||
" daoban = k1\n",
|
|
||||||
" num = v1['num']\n",
|
|
||||||
" avg = v1['avg']\n",
|
|
||||||
" list2 = [k,daoban,num,avg]\n",
|
|
||||||
" list1.append(list2)\n",
|
|
||||||
" \n",
|
" \n",
|
||||||
"filename = 'data/天津倒班因素分析表.xlsx' \n",
|
" num = dict2[k]['num']\n",
|
||||||
|
" score = dict2[k]['score']\n",
|
||||||
|
" if num > 0:\n",
|
||||||
|
" avg = round(score/num,2)\n",
|
||||||
|
" else:\n",
|
||||||
|
" avg = 0\n",
|
||||||
|
" zhongyi = dict2[k]['zhongyi']\n",
|
||||||
|
" pianpo = dict2[k]['pianpo']\n",
|
||||||
|
" list2 = [gld,num,avg,zhongyi,pianpo]\n",
|
||||||
|
" list1.append(list2)\n",
|
||||||
|
"filename = 'data/天津倒班因素分析表(年龄).xlsx' \n",
|
||||||
"wb = openpyxl.Workbook()\n",
|
"wb = openpyxl.Workbook()\n",
|
||||||
"sheet = wb.active\n",
|
"sheet = wb.active\n",
|
||||||
"\n",
|
"\n",
|
||||||
@@ -1145,7 +1347,7 @@
|
|||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
"id": "4fdc1484-ea69-4779-9a75-c52784cc9c7c",
|
"id": "93ae7587-e49d-41c2-bd57-f89b9eed37e4",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": []
|
"source": []
|
||||||
|
|||||||
Reference in new issue
Block a user