1874 lines
77 KiB
Plaintext
1874 lines
77 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 基础知识"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 正则表达式分割文本"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"import re\n",
|
||
"\n",
|
||
"file_name = 'data/药食材性味归经.xlsx'\n",
|
||
"wb = openpyxl.load_workbook(file_name)\n",
|
||
"sheet = wb.active\n",
|
||
"#sheets = wb.sheetnames\n",
|
||
"\n",
|
||
"list1 = []\n",
|
||
"dict1 = {}\n",
|
||
"mo =r'[。入归].+经$'\n",
|
||
"mo1 = r'[二]'\n",
|
||
"mo2 = r'[,、;]'\n",
|
||
"for n in range(2,sheet.max_row):\n",
|
||
" name = sheet.cell(n,1).value\n",
|
||
" content = re.findall(mo,sheet.cell(n,2).value)\n",
|
||
" if len(content) > 0:\n",
|
||
" l = len(content[0])\n",
|
||
" gj = re.sub(mo1, '', content[0][1:l-1]) \n",
|
||
" list_gj = re.split(mo2,gj)\n",
|
||
" dict1[sheet.cell(n,1).value ] = list_gj\n",
|
||
" #dict1['guijing'] = list_gj\n",
|
||
" \n",
|
||
"filename = './data/药食材归经.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl,ensure_ascii=False) \n",
|
||
"\n",
|
||
"#print(list1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import re\n",
|
||
"\n",
|
||
"s = '消化不良、胃下垂、急性胃炎、慢性胃炎、萎缩性胃炎、神经性呕吐、胆囊炎、胆石症、胆道蛔虫症、胸胁痛等'\n",
|
||
"ss = '健中和胃,消食止呕,理气疏郁,清热利胆。'\n",
|
||
"mo = '等$'\n",
|
||
"mo2 = r'[,、;。]'\n",
|
||
"s1 = re.sub(mo, '', s) \n",
|
||
"list1 = re.split(mo2,s1)\n",
|
||
"if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
"print(list1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import re\n",
|
||
"t = '5小时10分48秒'\n",
|
||
"m = re.match(r'(.*)小时(.*)分(.*)秒', t)\n",
|
||
"m.groups()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import re\n",
|
||
"t = '10分48秒'\n",
|
||
"list1 = []\n",
|
||
"if '小时' in t and '分' in t:\n",
|
||
" m = re.match(r'(.*)小时(.*)分(.*)秒', t)\n",
|
||
" list1 = [m[1],m[2],m[3]]\n",
|
||
"elif '小时' in t:\n",
|
||
" m = re.match(r'(.*)小时(.*)秒', t)\n",
|
||
" list1 = [m[1],0,m[2]]\n",
|
||
"elif '分' in t:\n",
|
||
" m = re.match(r'(.*)分(.*)秒', t)\n",
|
||
" list1 = [0,m[1],m[2]]\n",
|
||
"print(list1)\n",
|
||
"#m.group()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import re\n",
|
||
"\n",
|
||
"s = '2022-09-28-《气郁组》-视频学习详情_155229'\n",
|
||
"m = re.findall(r'《(.+)》',s)\n",
|
||
"print(m)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 日期计算"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import time\n",
|
||
"\n",
|
||
"birth = '1989-01-25'\n",
|
||
"t_birth = time.strptime(birth,'%Y-%m-%d')\n",
|
||
"days = (time.time() -time.mktime(t_birth))//(365*24*60*60)\n",
|
||
"print(int(days))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 字符串转换"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import binascii\n",
|
||
"\n",
|
||
"gbs = 'D4C0CDAF'\n",
|
||
"bs = binascii.a2b_hex(gbs)\n",
|
||
"print('bs', bs)\n",
|
||
"print('decode-bs:', bs.decode('gbk'))\n",
|
||
"\n",
|
||
"s = '马立亚'\n",
|
||
"gbcode = s.encode('gbk') # 先转成 bytes格式\n",
|
||
"print('gbcode:', gbcode)\n",
|
||
"gbs = \"\".join([hex(ch)[2:] for ch in gbcode]) #\n",
|
||
"print('gbs:', gbs)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"## 医药体测"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 药膳归经明细文件生成"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/药膳210927.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'data/药食材归经.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict2 = json.load(fl)\n",
|
||
"k_zy = dict2.keys()\n",
|
||
"dict3 = {}\n",
|
||
"list1 = []\n",
|
||
"for item in dict1:\n",
|
||
" print(item['name'])\n",
|
||
" list1 = []\n",
|
||
" #print(i,item['zy'])\n",
|
||
" for m_zy in item['zy']:\n",
|
||
" if m_zy in k_zy:\n",
|
||
" dict4 = {}\n",
|
||
" print(m_zy,dict2[m_zy])\n",
|
||
" dict4[m_zy] = dict2[m_zy]\n",
|
||
" list1.append(dict4)\n",
|
||
" dict3[item['name']] = list1\n",
|
||
"filename = './data/药膳药食材.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict3, fl,ensure_ascii=False) \n",
|
||
" \n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 药膳归经权重生成"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"import os,sys,shutil\n",
|
||
"\n",
|
||
"filename = './data/药膳药食材.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"list1 = []\n",
|
||
"for k, v in dict1.items():\n",
|
||
" if len(v) > 0 :\n",
|
||
" dict2 = {}\n",
|
||
" #print(k,v)\n",
|
||
" ys_name = k\n",
|
||
" dict2.setdefault(ys_name,{})\n",
|
||
" for item in v:\n",
|
||
" for k1, v1 in item.items():\n",
|
||
" for item1 in v1:\n",
|
||
" dict2[ys_name].setdefault(item1,0)\n",
|
||
" dict2[ys_name][item1] += 1\n",
|
||
" list1.append(dict2) \n",
|
||
" \n",
|
||
"dict_qz = {}\n",
|
||
"for item in list1:\n",
|
||
" for k, v in item.items():\n",
|
||
" qz = sorted(v.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)\n",
|
||
" dict_qz[k] = qz\n",
|
||
"#print(dict_qz)\n",
|
||
"qz_key = dict_qz.keys()\n",
|
||
"filename = 'data/药膳210927.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"#print(dict1)\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet['A1'] = '药膳名称'\n",
|
||
"sheet['B1'] = '来源'\n",
|
||
"sheet['C1'] = '配方'\n",
|
||
"sheet['D1'] = '做法'\n",
|
||
"sheet['E1'] = '功效'\n",
|
||
"sheet['F1'] = '中药成分'\n",
|
||
"sheet['G1'] = '归经权重'\n",
|
||
"\n",
|
||
"i =2\n",
|
||
"for item in dict1:\n",
|
||
" sheet[f'A{i}'] = item['name']\n",
|
||
" sheet[f'B{i}'] = item['source']\n",
|
||
" sheet[f'C{i}'] = item['pf']\n",
|
||
" sheet[f'D{i}'] = item['zf']\n",
|
||
" sheet[f'E{i}'] = item['gx']\n",
|
||
" sheet[f'F{i}'] = ','.join(item['zy'])\n",
|
||
" if item['name'] in qz_key:\n",
|
||
" s = ''\n",
|
||
" for m_gj in dict_qz[item['name']]:\n",
|
||
" s = s+ m_gj[0] +'('+str(m_gj[1])+')'\n",
|
||
" sheet[f'G{i}'] = s\n",
|
||
" else:\n",
|
||
" sheet[f'G{i}'] = '暂无归经'\n",
|
||
" i += 1\n",
|
||
"\n",
|
||
"wb.save('data/test4.xlsx') \n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 体质数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"#### 体质对应数据导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/tijianbingzheng.txt'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"m_key = set()\n",
|
||
"for k, v in dict1.items():\n",
|
||
" for item in v.keys():\n",
|
||
" m_key.add(item)\n",
|
||
"print(dict1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 穴位数据导入"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 简单导出简介、内容"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"dict1 = {}\n",
|
||
"filename = 'file/zhongyi/xuewei.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" #print(line1['title'],dict1)\n",
|
||
" #print(dict1.keys())\n",
|
||
" #print(line1)\n",
|
||
" dict1.setdefault(line1['title'][0],{})\n",
|
||
" dict1[line1['title'][0]]['简介'] = line1['jj'] \n",
|
||
" dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
"filename = './file/穴位1.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 数据导入文件中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"filename = 'file/zhongyi/xuewei.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1.setdefault(line1['title'][0],{})\n",
|
||
" if len(list3) > 0:\n",
|
||
" \n",
|
||
" dict1[line1['title'][0]]['about'] = list3\n",
|
||
" dict1[line1['title'][0]].setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1[line1['title'][0]]['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
"filename = './file/穴位1.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 穴位数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"#dblist = myclient.list_database_names()\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"xuewei\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/xuewei.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for s in list3:\n",
|
||
" item = s.strip().split(':')\n",
|
||
" dict1['about'][item[0].strip()] = item[1].strip()\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 中医症状数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"zhongyizhengzhuang\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/zhongyizhengzhuang.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for i in range(0,int(len(list3)/2)):\n",
|
||
" dict1['about'][list3[2*i]] = list3[2*i+1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 疾病数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"jibing\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/jibing.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for i in range(0,int(len(list3)/2)):\n",
|
||
" dict1['about'][list3[2*i]] = list3[2*i+1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 术语数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"#dblist = myclient.list_database_names()\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"shuyu\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/shuyu.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for s in list3:\n",
|
||
" item = s.strip().split(':')\n",
|
||
" dict1['about'][item[0]] = item[1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2021-12-15T10:01:32.917184Z",
|
||
"iopub.status.busy": "2021-12-15T10:01:32.917184Z",
|
||
"iopub.status.idle": "2021-12-15T10:01:32.921185Z",
|
||
"shell.execute_reply": "2021-12-15T10:01:32.921185Z",
|
||
"shell.execute_reply.started": "2021-12-15T10:01:32.917184Z"
|
||
},
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 西医症状数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"xiyizhengzhuang\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/xiyizhengzhuang.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for i in range(0,int(len(list3)/2)):\n",
|
||
" dict1['about'][list3[2*i]] = list3[2*i+1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 药剂数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"#dblist = myclient.list_database_names()\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"yaoji\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/yaoji.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj'] \n",
|
||
" dict2 = dict(zip(list1, list2)) \n",
|
||
" if len(list3) > 0: \n",
|
||
" jj = {}\n",
|
||
" for s in list3:\n",
|
||
" item = s.strip().split(':')\n",
|
||
" jj[item[0]] = item[1] \n",
|
||
" dict1['name'] = jj['名称']\n",
|
||
" dict1['about'] = jj\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 药膳数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"#dblist = myclient.list_database_names()\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"yaoshan\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/yaoshan.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for s in list3:\n",
|
||
" item = s.strip().split(':')\n",
|
||
" dict1['about'][item[0]] = item[1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"#### 中草药数据导入数据库中"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"zhongcaoyao\"]\n",
|
||
"db_list = []\n",
|
||
"filename = 'file/zhongyi/zhongcaoyao.json'\n",
|
||
"with open(filename,'r',encoding='utf-8') as fl:\n",
|
||
" for line in fl:\n",
|
||
" dict1 = {}\n",
|
||
" line1 = json.loads(re.sub(r'\\xa0','',line))\n",
|
||
" list1 = line1['tables']\n",
|
||
" list2 = line1['contents']\n",
|
||
" list3 = line1['jj']\n",
|
||
" dict2 = dict(zip(list1, list2))\n",
|
||
" dict1['name'] = line1['title'][0]\n",
|
||
" if len(list3) > 0:\n",
|
||
" dict1.setdefault('about',{})\n",
|
||
" for i in range(0,int(len(list3)/2)):\n",
|
||
" dict1['about'][list3[2*i]] = list3[2*i+1]\n",
|
||
" dict1.setdefault('content',{})\n",
|
||
" for k, v in dict2.items():\n",
|
||
" dict1['content'][k] = v \n",
|
||
" #dict1[line1['title'][0]]['内容'] = dict2\n",
|
||
" db_list.append(dict1)\n",
|
||
"x = mycol.insert_many(db_list)\n",
|
||
"print('ok!')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 穴位隶属整理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"xuewei\"]\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about.隶属\":1 }):\n",
|
||
" if 'about' in x.keys():\n",
|
||
" m_ls = x['about']['隶属']\n",
|
||
" dict1.setdefault(m_ls,[])\n",
|
||
" dict1[m_ls].append(x['name'])\n",
|
||
"'''\n",
|
||
"filename = './file/穴位隶属.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n",
|
||
"'''\n",
|
||
"for item in dict1.keys():\n",
|
||
" print(item)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 穴位功能、主治统计"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"xuewei\"]\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"mo = '等$'\n",
|
||
"mo2 = r'[,、;。]'\n",
|
||
"\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" dict1.setdefault(x['name'],{})\n",
|
||
" if '主治' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['主治']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['主治'] = list1\n",
|
||
" if '功能' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['功能']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['功能'] = list1\n",
|
||
" \n",
|
||
"\n",
|
||
"filename = './file/穴位主治功能统计.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 穴位数据导出Excel表"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"\n",
|
||
"filename = 'file/穴位.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" dict1 = json.load(fl)\n",
|
||
"filename = 'file/穴位简要情况表.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet['A1'] = '穴位名称'\n",
|
||
"sheet['B1'] = '隶属'\n",
|
||
"sheet['C1'] = '位置'\n",
|
||
"sheet['D1'] = '主治'\n",
|
||
"sheet['E1'] = '功能'\n",
|
||
"sheet['F1'] = '操作'\n",
|
||
"sheet['G1'] = '主要配伍'\n",
|
||
"i = 2\n",
|
||
"for k, v in dict1.items():\n",
|
||
" sheet[f'A{i}'] = k\n",
|
||
" sheet[f'B{i}'] = v['简介'][0].split(':')[1]\n",
|
||
" sheet[f'C{i}'] = v['简介'][1].split(':')[1]\n",
|
||
" sheet[f'D{i}'] = v['简介'][2].split(':')[1]\n",
|
||
" sheet[f'E{i}'] = v['简介'][3].split(':')[1]\n",
|
||
" sheet[f'F{i}'] = v['简介'][4].split(':')[1]\n",
|
||
" sheet[f'G{i}'] = v['简介'][5].split(':')[1] \n",
|
||
" i += 1\n",
|
||
"wb.save(filename) \n",
|
||
"print('ok!')\n",
|
||
"\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 术语数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"shuyu\"]\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" if '类别' in x['about'].keys():\n",
|
||
" m_lb = x['about']['类别'].replace(' ','')\n",
|
||
" else:\n",
|
||
" m_lb = '无类别'\n",
|
||
" dict1.setdefault(re.sub('\\xa0+','',m_lb),[])\n",
|
||
" dict1[m_lb].append(x['name'])\n",
|
||
"filename = './file/术语类别.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) \n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"jp-MarkdownHeadingCollapsed": true,
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 疾病数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"jibing\"]\n",
|
||
"dict1 = {}\n",
|
||
"list1 = []\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" if '疾病分类' in x['about'].keys():\n",
|
||
" m_lb = x['about']['疾病分类'].replace(' ','')\n",
|
||
" else:\n",
|
||
" m_lb = '无类别'\n",
|
||
" dict1.setdefault(re.sub('\\xa0+','',m_lb),[])\n",
|
||
" dict1[m_lb].append(x['name'])\n",
|
||
"filename = './file/疾病类别.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 中草药数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"zhongcaoyao\"]\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"mo = '等$'\n",
|
||
"mo2 = r'[,、;。]'\n",
|
||
"\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" dict1.setdefault(x['name'],{})\n",
|
||
" if '别名' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['别名']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['别名'] = list1\n",
|
||
" if '功能' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['功能']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['功能'] = list1\n",
|
||
" if '主治' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" dict1[x['name']]['主治'] = s = x['about']['主治']\n",
|
||
" \n",
|
||
"\n",
|
||
"filename = './file/中草药主治功能统计.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 药剂数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"yaoji\"]\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"mo = '等$'\n",
|
||
"mo2 = r'[,、;。]'\n",
|
||
"\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" dict1.setdefault(x['name'],{})\n",
|
||
" if '功用' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['功用']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['功用'] = list1\n",
|
||
" if '主治' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" dict1[x['name']]['主治'] = s = x['about']['主治']\n",
|
||
" \n",
|
||
"\n",
|
||
"filename = './file/药剂主治功用统计.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 药膳数据处理"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import re\n",
|
||
"import pymongo\n",
|
||
"\n",
|
||
"myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')\n",
|
||
"mydb = myclient['dayi']\n",
|
||
"mycol = mydb[\"yaoshan\"]\n",
|
||
"\n",
|
||
"dict1 = {}\n",
|
||
"mo = '等$'\n",
|
||
"mo2 = r'[,、;。]'\n",
|
||
"\n",
|
||
"for x in mycol.find({},{ \"_id\": 0,\"name\":1,\"about\":1 }):\n",
|
||
" dict1.setdefault(x['name'],{})\n",
|
||
" if '功效' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['功效']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['功效'] = list1\n",
|
||
" if '相关疾病' in x['about'].keys():\n",
|
||
" #dict1[x['name']].setdefault('主治',[])\n",
|
||
" s = x['about']['相关疾病']\n",
|
||
" s1 = re.sub(mo, '', s)\n",
|
||
" list1 = re.split(mo2,s1)\n",
|
||
" if '' in list1:\n",
|
||
" list1.remove('')\n",
|
||
" dict1[x['name']]['相关疾病'] = list1 \n",
|
||
" \n",
|
||
"\n",
|
||
"filename = './file/药膳功能统计.json'\n",
|
||
"with open(filename,'w') as fl:\n",
|
||
" json.dump(dict1, fl) "
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"source": [
|
||
"### 北海炼化体检数据提取"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import json\n",
|
||
"import openpyxl\n",
|
||
"import os,sys,shutil\n",
|
||
"\n",
|
||
"file_name = 'file/中石化北海炼化2020年团体体检报告.xlsx'\n",
|
||
"wb = openpyxl.load_workbook(file_name)\n",
|
||
"sheet = wb.active\n",
|
||
"dict1 = {}\n",
|
||
"for n in range(1,sheet.max_row+1):\n",
|
||
" bh = sheet.cell(n,2).value\n",
|
||
" name = sheet.cell(n,3).value\n",
|
||
" xb = sheet.cell(n,4).value\n",
|
||
" nl = sheet.cell(n,5).value\n",
|
||
" bz = sheet.cell(n,7).value\n",
|
||
" dict1.setdefault(bh,{})\n",
|
||
" dict1[bh]['姓名'] = name\n",
|
||
" dict1[bh]['性别'] = xb\n",
|
||
" dict1[bh]['年龄'] = nl\n",
|
||
" dict1[bh].setdefault('病症',[])\n",
|
||
" dict1[bh]['病症'].append(bz.strip())\n",
|
||
"wb.close()\n",
|
||
"#print(dict1)\n",
|
||
" \n",
|
||
" \n",
|
||
"filename = 'file/中石化北海炼化2020年体检人员情况表.xlsx'\n",
|
||
"wb = openpyxl.Workbook()\n",
|
||
"sheet = wb.active\n",
|
||
"sheet['A1'] = '体检编号'\n",
|
||
"sheet['B1'] = '姓名'\n",
|
||
"sheet['C1'] = '性别'\n",
|
||
"sheet['D1'] = '年龄'\n",
|
||
"sheet['E1'] = '异常名称'\n",
|
||
"\n",
|
||
"i =2\n",
|
||
"for k, v in dict1.items():\n",
|
||
" sheet[f'A{i}'] = k\n",
|
||
" sheet[f'B{i}'] = v['姓名']\n",
|
||
" sheet[f'C{i}'] = v['性别']\n",
|
||
" sheet[f'D{i}'] = v['年龄']\n",
|
||
" sheet[f'E{i}'] = ','.join(v['病症']) \n",
|
||
" i += 1\n",
|
||
"wb.save(filename)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## excel数据读取"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import openpyxl\n",
|
||
"import json\n",
|
||
"\n",
|
||
"filename = 'data/长岭全成绩.xlsx'\n",
|
||
"wb = openpyxl.load_workbook(filename)\n",
|
||
"sheet = wb.active\n",
|
||
"data1 =list(sheet.values)\n",
|
||
"del data1[0]\n",
|
||
"print(data1)\n",
|
||
"#for data in data1:\n",
|
||
"# print(data)\n",
|
||
"\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"## 图表生成"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 高考一分一段表生成"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"from pyecharts.globals import CurrentConfig, NotebookType\n",
|
||
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
|
||
"from pyecharts import options as opts\n",
|
||
"from pyecharts.charts import Bar,Line\n",
|
||
"import pyecharts.options as opts\n",
|
||
"from pyecharts.faker import Faker\n",
|
||
"import json\n",
|
||
"\n",
|
||
"list_x = []\n",
|
||
"list_y = []\n",
|
||
"filename = 'data/17-21年一分一段表.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" m_xx = json.load(fl)\n",
|
||
"dict1 =m_xx['2020']['z']\n",
|
||
"for i in sorted(dict1,reverse=True): #降序\n",
|
||
" list_x.append(i)\n",
|
||
" list_y.append(dict1[i]['num_person'])\n",
|
||
" #print(i,dict1[i]['num_person'])\n",
|
||
"bar = (\n",
|
||
" Bar()\n",
|
||
" .add_xaxis(list_x)\n",
|
||
" .add_yaxis(\"2020年一分一段表\", list_y, category_gap=0, color=Faker.rand_color())\n",
|
||
" .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
|
||
" .set_global_opts(title_opts=opts.TitleOpts(title=\"Bar-直方图\"))\n",
|
||
" .render(\"bar_histogram2020.html\")\n",
|
||
"# .set_global_opts(title_opts=opts.TitleOpts(title=\"运动步幅及步频\", subtitle=\"户外运动\"),)\n",
|
||
")\n",
|
||
"#bar.load_javascript()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"bar.render_notebook()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": [
|
||
"from pyecharts.globals import CurrentConfig, NotebookType\n",
|
||
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
|
||
"from pyecharts import options as opts\n",
|
||
"from pyecharts.charts import Bar,Line\n",
|
||
"import pyecharts.options as opts\n",
|
||
"from pyecharts.faker import Faker\n",
|
||
"import json\n",
|
||
"\n",
|
||
"x_2021 = []\n",
|
||
"y_2021 = []\n",
|
||
"x_2020 = []\n",
|
||
"y_2020 = []\n",
|
||
"filename = 'data/17-21年一分一段表.json'\n",
|
||
"with open(filename,'r') as fl:\n",
|
||
" m_xx = json.load(fl)\n",
|
||
"dict1 =m_xx['2021']['z']\n",
|
||
"for i in sorted(dict1,reverse=True): #降序\n",
|
||
" x_2021.append(i)\n",
|
||
" y_2021.append(dict1[i]['num_person'])\n",
|
||
"dict1 =m_xx['2020']['z']\n",
|
||
"for i in sorted(dict1,reverse=True): #降序\n",
|
||
" x_2021.append(i)\n",
|
||
" y_2021.append(dict1[i]['num_person'])\n",
|
||
" #print(i,dict1[i]['num_person'])\n",
|
||
"bar = (\n",
|
||
" Bar()\n",
|
||
" .add_xaxis(list_x)\n",
|
||
" .add_yaxis(\"人数\", list_y, category_gap=0, color=Faker.rand_color())\n",
|
||
" .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
|
||
" .set_global_opts(title_opts=opts.TitleOpts(title=\"Bar-直方图\"))\n",
|
||
" .render(\"bar_histogram.html\")\n"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {},
|
||
"source": [
|
||
"### 生成雷达图"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 18,
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-10-08T02:00:19.557430Z",
|
||
"iopub.status.busy": "2023-10-08T02:00:19.556961Z",
|
||
"iopub.status.idle": "2023-10-08T02:00:19.571800Z",
|
||
"shell.execute_reply": "2023-10-08T02:00:19.571393Z",
|
||
"shell.execute_reply.started": "2023-10-08T02:00:19.557394Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"application/javascript": [
|
||
"new Promise(function(resolve, reject) {\n",
|
||
" var script = document.createElement(\"script\");\n",
|
||
" script.onload = resolve;\n",
|
||
" script.onerror = reject;\n",
|
||
" script.src = \"https://assets.pyecharts.org/assets/v5/echarts.min.js\";\n",
|
||
" document.head.appendChild(script);\n",
|
||
"}).then(() => {\n",
|
||
"\n",
|
||
"});"
|
||
],
|
||
"text/plain": [
|
||
"<pyecharts.render.display.Javascript at 0x7f28396390c0>"
|
||
]
|
||
},
|
||
"execution_count": 18,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"from pyecharts.globals import CurrentConfig, NotebookType\n",
|
||
"import pyecharts.options as opts\n",
|
||
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
|
||
"from pyecharts.charts import Radar\n",
|
||
"\n",
|
||
"\n",
|
||
"v1 = [[90, 100, 80, 76, 88, 95]]\n",
|
||
"v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]\n",
|
||
"\n",
|
||
"bar =(\n",
|
||
" Radar(init_opts=opts.InitOpts())\n",
|
||
" .add_schema(\n",
|
||
" schema=[\n",
|
||
" opts.RadarIndicatorItem(name=\"销售(sales)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"管理(Administration)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"信息技术(Information Technology)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"客服(Customer Support)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"研发(Development)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"市场(Marketing)\", max_=100),\n",
|
||
" ],\n",
|
||
" splitarea_opt=opts.SplitAreaOpts(\n",
|
||
" is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)\n",
|
||
" ),\n",
|
||
" textstyle_opts=opts.TextStyleOpts(color=\"#aaa\"),\n",
|
||
" )\n",
|
||
" .add(\n",
|
||
" series_name=\"预算分配(Allocated Budget)\",\n",
|
||
" data=v1,\n",
|
||
" linestyle_opts=opts.LineStyleOpts(color=\"#CD0000\"),\n",
|
||
" )\n",
|
||
" \n",
|
||
" .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
|
||
" .set_global_opts(\n",
|
||
" title_opts=opts.TitleOpts(title=\"基础雷达图\"), legend_opts=opts.LegendOpts()\n",
|
||
" )\n",
|
||
" #.render(\"basic_radar_chart.html\")\n",
|
||
" \n",
|
||
")\n",
|
||
"bar.load_javascript()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 19,
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-10-08T02:00:22.378306Z",
|
||
"iopub.status.busy": "2023-10-08T02:00:22.377831Z",
|
||
"iopub.status.idle": "2023-10-08T02:00:22.387577Z",
|
||
"shell.execute_reply": "2023-10-08T02:00:22.386538Z",
|
||
"shell.execute_reply.started": "2023-10-08T02:00:22.378268Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"text/html": [
|
||
"<!DOCTYPE html>\n",
|
||
"<html>\n",
|
||
"<head>\n",
|
||
" <meta charset=\"UTF-8\">\n",
|
||
"</head>\n",
|
||
"<body>\n",
|
||
" <div id=\"b433fb69b1da41429671453eeed62046\" class=\"chart-container\" style=\"width:900px; height:500px; \"></div>\n",
|
||
" <script>\n",
|
||
" var chart_b433fb69b1da41429671453eeed62046 = echarts.init(\n",
|
||
" document.getElementById('b433fb69b1da41429671453eeed62046'), 'white', {renderer: 'canvas'});\n",
|
||
" var option_b433fb69b1da41429671453eeed62046 = {\n",
|
||
" \"animation\": true,\n",
|
||
" \"animationThreshold\": 2000,\n",
|
||
" \"animationDuration\": 1000,\n",
|
||
" \"animationEasing\": \"cubicOut\",\n",
|
||
" \"animationDelay\": 0,\n",
|
||
" \"animationDurationUpdate\": 300,\n",
|
||
" \"animationEasingUpdate\": \"cubicOut\",\n",
|
||
" \"animationDelayUpdate\": 0,\n",
|
||
" \"aria\": {\n",
|
||
" \"enabled\": false\n",
|
||
" },\n",
|
||
" \"color\": [\n",
|
||
" \"#5470c6\",\n",
|
||
" \"#91cc75\",\n",
|
||
" \"#fac858\",\n",
|
||
" \"#ee6666\",\n",
|
||
" \"#73c0de\",\n",
|
||
" \"#3ba272\",\n",
|
||
" \"#fc8452\",\n",
|
||
" \"#9a60b4\",\n",
|
||
" \"#ea7ccc\"\n",
|
||
" ],\n",
|
||
" \"series\": [\n",
|
||
" {\n",
|
||
" \"type\": \"radar\",\n",
|
||
" \"name\": \"\\u9884\\u7b97\\u5206\\u914d\\uff08Allocated Budget\\uff09\",\n",
|
||
" \"data\": [\n",
|
||
" [\n",
|
||
" 90,\n",
|
||
" 100,\n",
|
||
" 80,\n",
|
||
" 76,\n",
|
||
" 88,\n",
|
||
" 95\n",
|
||
" ]\n",
|
||
" ],\n",
|
||
" \"label\": {\n",
|
||
" \"show\": false,\n",
|
||
" \"margin\": 8\n",
|
||
" },\n",
|
||
" \"itemStyle\": {\n",
|
||
" \"normal\": {}\n",
|
||
" },\n",
|
||
" \"lineStyle\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"width\": 1,\n",
|
||
" \"opacity\": 1,\n",
|
||
" \"curveness\": 0,\n",
|
||
" \"type\": \"solid\",\n",
|
||
" \"color\": \"#CD0000\"\n",
|
||
" },\n",
|
||
" \"areaStyle\": {\n",
|
||
" \"opacity\": 0\n",
|
||
" },\n",
|
||
" \"rippleEffect\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"brushType\": \"stroke\",\n",
|
||
" \"scale\": 2.5,\n",
|
||
" \"period\": 4\n",
|
||
" }\n",
|
||
" }\n",
|
||
" ],\n",
|
||
" \"legend\": [\n",
|
||
" {\n",
|
||
" \"data\": [\n",
|
||
" \"\\u9884\\u7b97\\u5206\\u914d\\uff08Allocated Budget\\uff09\"\n",
|
||
" ],\n",
|
||
" \"selected\": {},\n",
|
||
" \"show\": true,\n",
|
||
" \"padding\": 5,\n",
|
||
" \"itemGap\": 10,\n",
|
||
" \"itemWidth\": 25,\n",
|
||
" \"itemHeight\": 14,\n",
|
||
" \"backgroundColor\": \"transparent\",\n",
|
||
" \"borderColor\": \"#ccc\",\n",
|
||
" \"borderWidth\": 1,\n",
|
||
" \"borderRadius\": 0,\n",
|
||
" \"pageButtonItemGap\": 5,\n",
|
||
" \"pageButtonPosition\": \"end\",\n",
|
||
" \"pageFormatter\": \"{current}/{total}\",\n",
|
||
" \"pageIconColor\": \"#2f4554\",\n",
|
||
" \"pageIconInactiveColor\": \"#aaa\",\n",
|
||
" \"pageIconSize\": 15,\n",
|
||
" \"animationDurationUpdate\": 800,\n",
|
||
" \"selector\": false,\n",
|
||
" \"selectorPosition\": \"auto\",\n",
|
||
" \"selectorItemGap\": 7,\n",
|
||
" \"selectorButtonGap\": 10\n",
|
||
" }\n",
|
||
" ],\n",
|
||
" \"tooltip\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"trigger\": \"item\",\n",
|
||
" \"triggerOn\": \"mousemove|click\",\n",
|
||
" \"axisPointer\": {\n",
|
||
" \"type\": \"line\"\n",
|
||
" },\n",
|
||
" \"showContent\": true,\n",
|
||
" \"alwaysShowContent\": false,\n",
|
||
" \"showDelay\": 0,\n",
|
||
" \"hideDelay\": 100,\n",
|
||
" \"enterable\": false,\n",
|
||
" \"confine\": false,\n",
|
||
" \"appendToBody\": false,\n",
|
||
" \"transitionDuration\": 0.4,\n",
|
||
" \"textStyle\": {\n",
|
||
" \"fontSize\": 14\n",
|
||
" },\n",
|
||
" \"borderWidth\": 0,\n",
|
||
" \"padding\": 5,\n",
|
||
" \"order\": \"seriesAsc\"\n",
|
||
" },\n",
|
||
" \"radar\": [\n",
|
||
" {\n",
|
||
" \"indicator\": [\n",
|
||
" {\n",
|
||
" \"name\": \"\\u9500\\u552e\\uff08sales\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" },\n",
|
||
" {\n",
|
||
" \"name\": \"\\u7ba1\\u7406\\uff08Administration\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" },\n",
|
||
" {\n",
|
||
" \"name\": \"\\u4fe1\\u606f\\u6280\\u672f\\uff08Information Technology\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" },\n",
|
||
" {\n",
|
||
" \"name\": \"\\u5ba2\\u670d\\uff08Customer Support\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" },\n",
|
||
" {\n",
|
||
" \"name\": \"\\u7814\\u53d1\\uff08Development\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" },\n",
|
||
" {\n",
|
||
" \"name\": \"\\u5e02\\u573a\\uff08Marketing\\uff09\",\n",
|
||
" \"max\": 100\n",
|
||
" }\n",
|
||
" ],\n",
|
||
" \"startAngle\": 90,\n",
|
||
" \"name\": {\n",
|
||
" \"textStyle\": {\n",
|
||
" \"color\": \"#aaa\"\n",
|
||
" }\n",
|
||
" },\n",
|
||
" \"splitLine\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"lineStyle\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"width\": 1,\n",
|
||
" \"opacity\": 1,\n",
|
||
" \"curveness\": 0,\n",
|
||
" \"type\": \"solid\"\n",
|
||
" }\n",
|
||
" },\n",
|
||
" \"splitArea\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"areaStyle\": {\n",
|
||
" \"opacity\": 1\n",
|
||
" }\n",
|
||
" },\n",
|
||
" \"axisLine\": {\n",
|
||
" \"show\": true,\n",
|
||
" \"onZero\": true,\n",
|
||
" \"onZeroAxisIndex\": 0\n",
|
||
" }\n",
|
||
" }\n",
|
||
" ],\n",
|
||
" \"title\": [\n",
|
||
" {\n",
|
||
" \"show\": true,\n",
|
||
" \"text\": \"\\u57fa\\u7840\\u96f7\\u8fbe\\u56fe\",\n",
|
||
" \"target\": \"blank\",\n",
|
||
" \"subtarget\": \"blank\",\n",
|
||
" \"padding\": 5,\n",
|
||
" \"itemGap\": 10,\n",
|
||
" \"textAlign\": \"auto\",\n",
|
||
" \"textVerticalAlign\": \"auto\",\n",
|
||
" \"triggerEvent\": false\n",
|
||
" }\n",
|
||
" ]\n",
|
||
"};\n",
|
||
" chart_b433fb69b1da41429671453eeed62046.setOption(option_b433fb69b1da41429671453eeed62046);\n",
|
||
" </script>\n",
|
||
"</body>\n",
|
||
"</html>\n"
|
||
],
|
||
"text/plain": [
|
||
"<pyecharts.render.display.HTML at 0x7f284b792020>"
|
||
]
|
||
},
|
||
"execution_count": 19,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"bar.render_notebook()"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-10-08T02:09:05.895554Z",
|
||
"iopub.status.busy": "2023-10-08T02:09:05.895353Z",
|
||
"iopub.status.idle": "2023-10-08T02:09:06.036187Z",
|
||
"shell.execute_reply": "2023-10-08T02:09:06.035511Z",
|
||
"shell.execute_reply.started": "2023-10-08T02:09:05.895538Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stderr",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"No phantomjs found in your PATH. Please install it!\n"
|
||
]
|
||
},
|
||
{
|
||
"ename": "AttributeError",
|
||
"evalue": "'tuple' object has no attribute 'tb_frame'",
|
||
"output_type": "error",
|
||
"traceback": [
|
||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||
"\u001b[0;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:44\u001b[0m, in \u001b[0;36mchk_phantomjs\u001b[0;34m()\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 44\u001b[0m phantomjs_version \u001b[38;5;241m=\u001b[39m \u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcheck_output\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 45\u001b[0m \u001b[43m \u001b[49m\u001b[43m[\u001b[49m\u001b[43mPHANTOMJS_EXEC\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m--version\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mshell\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mget_shell_flag\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 46\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 47\u001b[0m phantomjs_version \u001b[38;5;241m=\u001b[39m phantomjs_version\u001b[38;5;241m.\u001b[39mdecode(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mutf-8\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:421\u001b[0m, in \u001b[0;36mcheck_output\u001b[0;34m(timeout, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m 419\u001b[0m kwargs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124minput\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m empty\n\u001b[0;32m--> 421\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mpopenargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstdout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mPIPE\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtimeout\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mtimeout\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcheck\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m 422\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\u001b[38;5;241m.\u001b[39mstdout\n",
|
||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:503\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m 501\u001b[0m kwargs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mstderr\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m PIPE\n\u001b[0;32m--> 503\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[43mPopen\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mpopenargs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mas\u001b[39;00m process:\n\u001b[1;32m 504\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n",
|
||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:971\u001b[0m, in \u001b[0;36mPopen.__init__\u001b[0;34m(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize)\u001b[0m\n\u001b[1;32m 968\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstderr \u001b[38;5;241m=\u001b[39m io\u001b[38;5;241m.\u001b[39mTextIOWrapper(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mstderr,\n\u001b[1;32m 969\u001b[0m encoding\u001b[38;5;241m=\u001b[39mencoding, errors\u001b[38;5;241m=\u001b[39merrors)\n\u001b[0;32m--> 971\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_execute_child\u001b[49m\u001b[43m(\u001b[49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexecutable\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpreexec_fn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mclose_fds\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 972\u001b[0m \u001b[43m \u001b[49m\u001b[43mpass_fds\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcwd\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43menv\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 973\u001b[0m \u001b[43m \u001b[49m\u001b[43mstartupinfo\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcreationflags\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mshell\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 974\u001b[0m \u001b[43m \u001b[49m\u001b[43mp2cread\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mp2cwrite\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 975\u001b[0m \u001b[43m \u001b[49m\u001b[43mc2pread\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mc2pwrite\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 976\u001b[0m \u001b[43m \u001b[49m\u001b[43merrread\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43merrwrite\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 977\u001b[0m \u001b[43m \u001b[49m\u001b[43mrestore_signals\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 978\u001b[0m \u001b[43m \u001b[49m\u001b[43mgid\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mgids\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43muid\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mumask\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 979\u001b[0m \u001b[43m \u001b[49m\u001b[43mstart_new_session\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 980\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[1;32m 981\u001b[0m \u001b[38;5;66;03m# Cleanup if the child failed starting.\u001b[39;00m\n",
|
||
"File \u001b[0;32m/usr/lib/python3.10/subprocess.py:1863\u001b[0m, in \u001b[0;36mPopen._execute_child\u001b[0;34m(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session)\u001b[0m\n\u001b[1;32m 1862\u001b[0m err_msg \u001b[38;5;241m=\u001b[39m os\u001b[38;5;241m.\u001b[39mstrerror(errno_num)\n\u001b[0;32m-> 1863\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m child_exception_type(errno_num, err_msg, err_filename)\n\u001b[1;32m 1864\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m child_exception_type(err_msg)\n",
|
||
"\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'phantomjs'",
|
||
"\nDuring handling of the above exception, another exception occurred:\n",
|
||
"\u001b[0;31mSystemExit\u001b[0m Traceback (most recent call last)",
|
||
" \u001b[0;31m[... skipping hidden 1 frame]\u001b[0m\n",
|
||
"Cell \u001b[0;32mIn[21], line 41\u001b[0m\n\u001b[1;32m 12\u001b[0m bar \u001b[38;5;241m=\u001b[39m(\n\u001b[1;32m 13\u001b[0m Radar(init_opts\u001b[38;5;241m=\u001b[39mopts\u001b[38;5;241m.\u001b[39mInitOpts())\n\u001b[1;32m 14\u001b[0m \u001b[38;5;241m.\u001b[39madd_schema(\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 39\u001b[0m \n\u001b[1;32m 40\u001b[0m )\n\u001b[0;32m---> 41\u001b[0m \u001b[43mmake_snapshot\u001b[49m\u001b[43m(\u001b[49m\u001b[43msnapshot\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbar\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrender\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbar0.png\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/pyecharts/render/snapshot.py:32\u001b[0m, in \u001b[0;36mmake_snapshot\u001b[0;34m(engine, file_name, output_name, delay, pixel_ratio, is_remove_html, **kwargs)\u001b[0m\n\u001b[1;32m 30\u001b[0m file_type \u001b[38;5;241m=\u001b[39m output_name\u001b[38;5;241m.\u001b[39msplit(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m.\u001b[39m\u001b[38;5;124m\"\u001b[39m)[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m]\n\u001b[0;32m---> 32\u001b[0m content \u001b[38;5;241m=\u001b[39m \u001b[43mengine\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mmake_snapshot\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 33\u001b[0m \u001b[43m \u001b[49m\u001b[43mhtml_path\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfile_name\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 34\u001b[0m \u001b[43m \u001b[49m\u001b[43mfile_type\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mfile_type\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 35\u001b[0m \u001b[43m \u001b[49m\u001b[43mdelay\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdelay\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 36\u001b[0m \u001b[43m \u001b[49m\u001b[43mpixel_ratio\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mpixel_ratio\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 37\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 38\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m file_type \u001b[38;5;129;01min\u001b[39;00m [SVG_FORMAT, B64_FORMAT]:\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:15\u001b[0m, in \u001b[0;36mmake_snapshot\u001b[0;34m(html_path, file_type, delay, pixel_ratio, **_)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mmake_snapshot\u001b[39m(\n\u001b[1;32m 13\u001b[0m html_path: \u001b[38;5;28mstr\u001b[39m, file_type: \u001b[38;5;28mstr\u001b[39m, delay: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m, pixel_ratio: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39m_\n\u001b[1;32m 14\u001b[0m ):\n\u001b[0;32m---> 15\u001b[0m \u001b[43mchk_phantomjs\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 16\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mGenerating file ...\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:51\u001b[0m, in \u001b[0;36mchk_phantomjs\u001b[0;34m()\u001b[0m\n\u001b[1;32m 50\u001b[0m logger\u001b[38;5;241m.\u001b[39mwarning(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mNo phantomjs found in your PATH. Please install it!\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 51\u001b[0m \u001b[43msys\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexit\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n",
|
||
"\u001b[0;31mSystemExit\u001b[0m: 1",
|
||
"\nDuring handling of the above exception, another exception occurred:\n",
|
||
"\u001b[0;31mAttributeError\u001b[0m Traceback (most recent call last)",
|
||
" \u001b[0;31m[... skipping hidden 1 frame]\u001b[0m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2097\u001b[0m, in \u001b[0;36mInteractiveShell.showtraceback\u001b[0;34m(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)\u001b[0m\n\u001b[1;32m 2094\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m exception_only:\n\u001b[1;32m 2095\u001b[0m stb \u001b[38;5;241m=\u001b[39m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mAn exception has occurred, use \u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mtb to see \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 2096\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mthe full traceback.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m'\u001b[39m]\n\u001b[0;32m-> 2097\u001b[0m stb\u001b[38;5;241m.\u001b[39mextend(\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mInteractiveTB\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_exception_only\u001b[49m\u001b[43m(\u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 2098\u001b[0m \u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m)\n\u001b[1;32m 2099\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 2101\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcontains_exceptiongroup\u001b[39m(val):\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:710\u001b[0m, in \u001b[0;36mListTB.get_exception_only\u001b[0;34m(self, etype, value)\u001b[0m\n\u001b[1;32m 702\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mget_exception_only\u001b[39m(\u001b[38;5;28mself\u001b[39m, etype, value):\n\u001b[1;32m 703\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Only print the exception type and message, without a traceback.\u001b[39;00m\n\u001b[1;32m 704\u001b[0m \n\u001b[1;32m 705\u001b[0m \u001b[38;5;124;03m Parameters\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 708\u001b[0m \u001b[38;5;124;03m value : exception value\u001b[39;00m\n\u001b[1;32m 709\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 710\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mListTB\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstructured_traceback\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m)\u001b[49m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:568\u001b[0m, in \u001b[0;36mListTB.structured_traceback\u001b[0;34m(self, etype, evalue, etb, tb_offset, context)\u001b[0m\n\u001b[1;32m 565\u001b[0m chained_exc_ids\u001b[38;5;241m.\u001b[39madd(\u001b[38;5;28mid\u001b[39m(exception[\u001b[38;5;241m1\u001b[39m]))\n\u001b[1;32m 566\u001b[0m chained_exceptions_tb_offset \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n\u001b[1;32m 567\u001b[0m out_list \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m--> 568\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstructured_traceback\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 569\u001b[0m \u001b[43m \u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 570\u001b[0m \u001b[43m \u001b[49m\u001b[43mevalue\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 571\u001b[0m \u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43metb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchained_exc_ids\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;66;43;03m# type: ignore\u001b[39;49;00m\n\u001b[1;32m 572\u001b[0m \u001b[43m \u001b[49m\u001b[43mchained_exceptions_tb_offset\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 573\u001b[0m \u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 574\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 575\u001b[0m \u001b[38;5;241m+\u001b[39m chained_exception_message\n\u001b[1;32m 576\u001b[0m \u001b[38;5;241m+\u001b[39m out_list)\n\u001b[1;32m 578\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m out_list\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1435\u001b[0m, in \u001b[0;36mAutoFormattedTB.structured_traceback\u001b[0;34m(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1433\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 1434\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mtb \u001b[38;5;241m=\u001b[39m etb\n\u001b[0;32m-> 1435\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mFormattedTB\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstructured_traceback\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1436\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mevalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43metb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtb_offset\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnumber_of_lines_of_context\u001b[49m\n\u001b[1;32m 1437\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1326\u001b[0m, in \u001b[0;36mFormattedTB.structured_traceback\u001b[0;34m(self, etype, value, tb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1323\u001b[0m mode \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mmode\n\u001b[1;32m 1324\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m mode \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mverbose_modes:\n\u001b[1;32m 1325\u001b[0m \u001b[38;5;66;03m# Verbose modes need a full traceback\u001b[39;00m\n\u001b[0;32m-> 1326\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mVerboseTB\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mstructured_traceback\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m 1327\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mvalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtb_offset\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnumber_of_lines_of_context\u001b[49m\n\u001b[1;32m 1328\u001b[0m \u001b[43m \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1329\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m mode \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mMinimal\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[1;32m 1330\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m ListTB\u001b[38;5;241m.\u001b[39mget_exception_only(\u001b[38;5;28mself\u001b[39m, etype, value)\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1173\u001b[0m, in \u001b[0;36mVerboseTB.structured_traceback\u001b[0;34m(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)\u001b[0m\n\u001b[1;32m 1164\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mstructured_traceback\u001b[39m(\n\u001b[1;32m 1165\u001b[0m \u001b[38;5;28mself\u001b[39m,\n\u001b[1;32m 1166\u001b[0m etype: \u001b[38;5;28mtype\u001b[39m,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1170\u001b[0m number_of_lines_of_context: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m5\u001b[39m,\n\u001b[1;32m 1171\u001b[0m ):\n\u001b[1;32m 1172\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"Return a nice text document describing the traceback.\"\"\"\u001b[39;00m\n\u001b[0;32m-> 1173\u001b[0m formatted_exception \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mformat_exception_as_a_whole\u001b[49m\u001b[43m(\u001b[49m\u001b[43metype\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mevalue\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43metb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnumber_of_lines_of_context\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m 1174\u001b[0m \u001b[43m \u001b[49m\u001b[43mtb_offset\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1176\u001b[0m colors \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mColors \u001b[38;5;66;03m# just a shorthand + quicker name lookup\u001b[39;00m\n\u001b[1;32m 1177\u001b[0m colorsnormal \u001b[38;5;241m=\u001b[39m colors\u001b[38;5;241m.\u001b[39mNormal \u001b[38;5;66;03m# used a lot\u001b[39;00m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1063\u001b[0m, in \u001b[0;36mVerboseTB.format_exception_as_a_whole\u001b[0;34m(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)\u001b[0m\n\u001b[1;32m 1060\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(tb_offset, \u001b[38;5;28mint\u001b[39m)\n\u001b[1;32m 1061\u001b[0m head \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprepare_header(\u001b[38;5;28mstr\u001b[39m(etype), \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mlong_header)\n\u001b[1;32m 1062\u001b[0m records \u001b[38;5;241m=\u001b[39m (\n\u001b[0;32m-> 1063\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_records\u001b[49m\u001b[43m(\u001b[49m\u001b[43metb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mnumber_of_lines_of_context\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mtb_offset\u001b[49m\u001b[43m)\u001b[49m \u001b[38;5;28;01mif\u001b[39;00m etb \u001b[38;5;28;01melse\u001b[39;00m []\n\u001b[1;32m 1064\u001b[0m )\n\u001b[1;32m 1066\u001b[0m frames \u001b[38;5;241m=\u001b[39m []\n\u001b[1;32m 1067\u001b[0m skipped \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n",
|
||
"File \u001b[0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1131\u001b[0m, in \u001b[0;36mVerboseTB.get_records\u001b[0;34m(self, etb, number_of_lines_of_context, tb_offset)\u001b[0m\n\u001b[1;32m 1129\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m cf \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 1130\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m-> 1131\u001b[0m mod \u001b[38;5;241m=\u001b[39m inspect\u001b[38;5;241m.\u001b[39mgetmodule(\u001b[43mcf\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtb_frame\u001b[49m)\n\u001b[1;32m 1132\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m mod \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m 1133\u001b[0m mod_name \u001b[38;5;241m=\u001b[39m mod\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m\n",
|
||
"\u001b[0;31mAttributeError\u001b[0m: 'tuple' object has no attribute 'tb_frame'"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"from pyecharts.globals import CurrentConfig, NotebookType\n",
|
||
"import pyecharts.options as opts\n",
|
||
"CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB\n",
|
||
"from pyecharts.charts import Radar\n",
|
||
"from pyecharts.render import make_snapshot\n",
|
||
"from snapshot_phantomjs import snapshot\n",
|
||
"\n",
|
||
"\n",
|
||
"v1 = [[90, 100, 80, 76, 88, 95]]\n",
|
||
"v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]\n",
|
||
"\n",
|
||
"bar =(\n",
|
||
" Radar(init_opts=opts.InitOpts())\n",
|
||
" .add_schema(\n",
|
||
" schema=[\n",
|
||
" opts.RadarIndicatorItem(name=\"销售(sales)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"管理(Administration)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"信息技术(Information Technology)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"客服(Customer Support)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"研发(Development)\", max_=100),\n",
|
||
" opts.RadarIndicatorItem(name=\"市场(Marketing)\", max_=100),\n",
|
||
" ],\n",
|
||
" splitarea_opt=opts.SplitAreaOpts(\n",
|
||
" is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)\n",
|
||
" ),\n",
|
||
" textstyle_opts=opts.TextStyleOpts(color=\"#aaa\"),\n",
|
||
" )\n",
|
||
" .add(\n",
|
||
" series_name=\"预算分配(Allocated Budget)\",\n",
|
||
" data=v1,\n",
|
||
" linestyle_opts=opts.LineStyleOpts(color=\"#CD0000\"),\n",
|
||
" )\n",
|
||
" \n",
|
||
" .set_series_opts(label_opts=opts.LabelOpts(is_show=False))\n",
|
||
" .set_global_opts(\n",
|
||
" title_opts=opts.TitleOpts(title=\"基础雷达图\"), legend_opts=opts.LegendOpts()\n",
|
||
" )\n",
|
||
" #.render(\"basic_radar_chart.html\")\n",
|
||
" \n",
|
||
")\n",
|
||
"make_snapshot(snapshot, bar.render(), \"bar0.png\")"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 27,
|
||
"metadata": {
|
||
"execution": {
|
||
"iopub.execute_input": "2023-10-08T02:30:58.347196Z",
|
||
"iopub.status.busy": "2023-10-08T02:30:58.346801Z",
|
||
"iopub.status.idle": "2023-10-08T02:30:58.438868Z",
|
||
"shell.execute_reply": "2023-10-08T02:30:58.438412Z",
|
||
"shell.execute_reply.started": "2023-10-08T02:30:58.347165Z"
|
||
},
|
||
"tags": []
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"import pygal \n",
|
||
"\n",
|
||
"radar_chart = pygal.Radar()\n",
|
||
"radar_chart.title = 'V8 benchmark results'\n",
|
||
"radar_chart.x_labels = ['Richards', 'DeltaBlue', 'Crypto', 'RayTrace', 'EarleyBoyer', 'RegExp', 'Splay', 'NavierStokes']\n",
|
||
"radar_chart.add('Chrome', [6395, 8212, 7520, 7218, 12464, 1660, 2123, 8607])\n",
|
||
"\n",
|
||
"radar_chart.render_to_png('chart.png')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": null,
|
||
"metadata": {},
|
||
"outputs": [],
|
||
"source": []
|
||
}
|
||
],
|
||
"metadata": {
|
||
"kernelspec": {
|
||
"display_name": "Python 3 (ipykernel)",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.10.12"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 4
|
||
}
|