78 KiB
78 KiB
In [ ]:
import json
import openpyxl
import re
file_name = 'data/药食材性味归经.xlsx'
wb = openpyxl.load_workbook(file_name)
sheet = wb.active
#sheets = wb.sheetnames
list1 = []
dict1 = {}
mo =r'[。入归].+经$'
mo1 = r'[二]'
mo2 = r'[,、;]'
for n in range(2,sheet.max_row):
name = sheet.cell(n,1).value
content = re.findall(mo,sheet.cell(n,2).value)
if len(content) > 0:
l = len(content[0])
gj = re.sub(mo1, '', content[0][1:l-1])
list_gj = re.split(mo2,gj)
dict1[sheet.cell(n,1).value ] = list_gj
#dict1['guijing'] = list_gj
filename = './data/药食材归经.json'
with open(filename,'w') as fl:
json.dump(dict1, fl,ensure_ascii=False)
#print(list1)In [ ]:
import re
s = '消化不良、胃下垂、急性胃炎、慢性胃炎、萎缩性胃炎、神经性呕吐、胆囊炎、胆石症、胆道蛔虫症、胸胁痛等'
ss = '健中和胃,消食止呕,理气疏郁,清热利胆。'
mo = '等$'
mo2 = r'[,、;。]'
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
print(list1)In [ ]:
import re
t = '5小时10分48秒'
m = re.match(r'(.*)小时(.*)分(.*)秒', t)
m.groups()In [ ]:
import re
t = '10分48秒'
list1 = []
if '小时' in t and '分' in t:
m = re.match(r'(.*)小时(.*)分(.*)秒', t)
list1 = [m[1],m[2],m[3]]
elif '小时' in t:
m = re.match(r'(.*)小时(.*)秒', t)
list1 = [m[1],0,m[2]]
elif '分' in t:
m = re.match(r'(.*)分(.*)秒', t)
list1 = [0,m[1],m[2]]
print(list1)
#m.group()In [ ]:
import re
s = '2022-09-28-《气郁组》-视频学习详情_155229'
m = re.findall(r'《(.+)》',s)
print(m)In [ ]:
import time
birth = '1989-01-25'
t_birth = time.strptime(birth,'%Y-%m-%d')
days = (time.time() -time.mktime(t_birth))//(365*24*60*60)
print(int(days))In [ ]:
import binascii
gbs = 'D4C0CDAF'
bs = binascii.a2b_hex(gbs)
print('bs', bs)
print('decode-bs:', bs.decode('gbk'))
s = '马立亚'
gbcode = s.encode('gbk') # 先转成 bytes格式
print('gbcode:', gbcode)
gbs = "".join([hex(ch)[2:] for ch in gbcode]) #
print('gbs:', gbs)In [38]:
import itertools
list1 = ['气虚','阳虚','阴虚','痰湿','湿热','血瘀','气郁','特禀']
list2 = [0,1,2,3,4,5,6,7]
result=itertools.combinations(list1,7)
print(len(list(result)))
8
In [ ]:
import json
filename = 'data/药膳210927.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'data/药食材归经.json'
with open(filename,'r') as fl:
dict2 = json.load(fl)
k_zy = dict2.keys()
dict3 = {}
list1 = []
for item in dict1:
print(item['name'])
list1 = []
#print(i,item['zy'])
for m_zy in item['zy']:
if m_zy in k_zy:
dict4 = {}
print(m_zy,dict2[m_zy])
dict4[m_zy] = dict2[m_zy]
list1.append(dict4)
dict3[item['name']] = list1
filename = './data/药膳药食材.json'
with open(filename,'w') as fl:
json.dump(dict3, fl,ensure_ascii=False)
In [ ]:
import json
import openpyxl
import os,sys,shutil
filename = './data/药膳药食材.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
list1 = []
for k, v in dict1.items():
if len(v) > 0 :
dict2 = {}
#print(k,v)
ys_name = k
dict2.setdefault(ys_name,{})
for item in v:
for k1, v1 in item.items():
for item1 in v1:
dict2[ys_name].setdefault(item1,0)
dict2[ys_name][item1] += 1
list1.append(dict2)
dict_qz = {}
for item in list1:
for k, v in item.items():
qz = sorted(v.items(), key = lambda kv:(kv[1], kv[0]),reverse=True)
dict_qz[k] = qz
#print(dict_qz)
qz_key = dict_qz.keys()
filename = 'data/药膳210927.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
#print(dict1)
wb = openpyxl.Workbook()
sheet = wb.active
sheet['A1'] = '药膳名称'
sheet['B1'] = '来源'
sheet['C1'] = '配方'
sheet['D1'] = '做法'
sheet['E1'] = '功效'
sheet['F1'] = '中药成分'
sheet['G1'] = '归经权重'
i =2
for item in dict1:
sheet[f'A{i}'] = item['name']
sheet[f'B{i}'] = item['source']
sheet[f'C{i}'] = item['pf']
sheet[f'D{i}'] = item['zf']
sheet[f'E{i}'] = item['gx']
sheet[f'F{i}'] = ','.join(item['zy'])
if item['name'] in qz_key:
s = ''
for m_gj in dict_qz[item['name']]:
s = s+ m_gj[0] +'('+str(m_gj[1])+')'
sheet[f'G{i}'] = s
else:
sheet[f'G{i}'] = '暂无归经'
i += 1
wb.save('data/test4.xlsx')
In [ ]:
import json
filename = 'data/tijianbingzheng.txt'
with open(filename,'r') as fl:
dict1 = json.load(fl)
m_key = set()
for k, v in dict1.items():
for item in v.keys():
m_key.add(item)
print(dict1)In [ ]:
import json
import re
dict1 = {}
filename = 'file/zhongyi/xuewei.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
dict2 = dict(zip(list1, list2))
#print(line1['title'],dict1)
#print(dict1.keys())
#print(line1)
dict1.setdefault(line1['title'][0],{})
dict1[line1['title'][0]]['简介'] = line1['jj']
dict1[line1['title'][0]]['内容'] = dict2
filename = './file/穴位1.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import re
dict1 = {}
filename = 'file/zhongyi/xuewei.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1.setdefault(line1['title'][0],{})
if len(list3) > 0:
dict1[line1['title'][0]]['about'] = list3
dict1[line1['title'][0]].setdefault('content',{})
for k, v in dict2.items():
dict1[line1['title'][0]]['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
filename = './file/穴位1.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
#dblist = myclient.list_database_names()
mydb = myclient['dayi']
mycol = mydb["xuewei"]
db_list = []
filename = 'file/zhongyi/xuewei.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for s in list3:
item = s.strip().split(':')
dict1['about'][item[0].strip()] = item[1].strip()
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["zhongyizhengzhuang"]
db_list = []
filename = 'file/zhongyi/zhongyizhengzhuang.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for i in range(0,int(len(list3)/2)):
dict1['about'][list3[2*i]] = list3[2*i+1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["jibing"]
db_list = []
filename = 'file/zhongyi/jibing.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for i in range(0,int(len(list3)/2)):
dict1['about'][list3[2*i]] = list3[2*i+1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
#dblist = myclient.list_database_names()
mydb = myclient['dayi']
mycol = mydb["shuyu"]
db_list = []
filename = 'file/zhongyi/shuyu.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for s in list3:
item = s.strip().split(':')
dict1['about'][item[0]] = item[1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["xiyizhengzhuang"]
db_list = []
filename = 'file/zhongyi/xiyizhengzhuang.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for i in range(0,int(len(list3)/2)):
dict1['about'][list3[2*i]] = list3[2*i+1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
#dblist = myclient.list_database_names()
mydb = myclient['dayi']
mycol = mydb["yaoji"]
db_list = []
filename = 'file/zhongyi/yaoji.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
if len(list3) > 0:
jj = {}
for s in list3:
item = s.strip().split(':')
jj[item[0]] = item[1]
dict1['name'] = jj['名称']
dict1['about'] = jj
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
#dblist = myclient.list_database_names()
mydb = myclient['dayi']
mycol = mydb["yaoshan"]
db_list = []
filename = 'file/zhongyi/yaoshan.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for s in list3:
item = s.strip().split(':')
dict1['about'][item[0]] = item[1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["zhongcaoyao"]
db_list = []
filename = 'file/zhongyi/zhongcaoyao.json'
with open(filename,'r',encoding='utf-8') as fl:
for line in fl:
dict1 = {}
line1 = json.loads(re.sub(r'\xa0','',line))
list1 = line1['tables']
list2 = line1['contents']
list3 = line1['jj']
dict2 = dict(zip(list1, list2))
dict1['name'] = line1['title'][0]
if len(list3) > 0:
dict1.setdefault('about',{})
for i in range(0,int(len(list3)/2)):
dict1['about'][list3[2*i]] = list3[2*i+1]
dict1.setdefault('content',{})
for k, v in dict2.items():
dict1['content'][k] = v
#dict1[line1['title'][0]]['内容'] = dict2
db_list.append(dict1)
x = mycol.insert_many(db_list)
print('ok!')In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["xuewei"]
dict1 = {}
list1 = []
for x in mycol.find({},{ "_id": 0,"name":1,"about.隶属":1 }):
if 'about' in x.keys():
m_ls = x['about']['隶属']
dict1.setdefault(m_ls,[])
dict1[m_ls].append(x['name'])
'''
filename = './file/穴位隶属.json'
with open(filename,'w') as fl:
json.dump(dict1, fl)
'''
for item in dict1.keys():
print(item)In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["xuewei"]
dict1 = {}
mo = '等$'
mo2 = r'[,、;。]'
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
dict1.setdefault(x['name'],{})
if '主治' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['主治']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['主治'] = list1
if '功能' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['功能']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['功能'] = list1
filename = './file/穴位主治功能统计.json'
with open(filename,'w') as fl:
json.dump(dict1, fl)
In [ ]:
import json
import openpyxl
filename = 'file/穴位.json'
with open(filename,'r') as fl:
dict1 = json.load(fl)
filename = 'file/穴位简要情况表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet['A1'] = '穴位名称'
sheet['B1'] = '隶属'
sheet['C1'] = '位置'
sheet['D1'] = '主治'
sheet['E1'] = '功能'
sheet['F1'] = '操作'
sheet['G1'] = '主要配伍'
i = 2
for k, v in dict1.items():
sheet[f'A{i}'] = k
sheet[f'B{i}'] = v['简介'][0].split(':')[1]
sheet[f'C{i}'] = v['简介'][1].split(':')[1]
sheet[f'D{i}'] = v['简介'][2].split(':')[1]
sheet[f'E{i}'] = v['简介'][3].split(':')[1]
sheet[f'F{i}'] = v['简介'][4].split(':')[1]
sheet[f'G{i}'] = v['简介'][5].split(':')[1]
i += 1
wb.save(filename)
print('ok!')
In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["shuyu"]
dict1 = {}
list1 = []
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
if '类别' in x['about'].keys():
m_lb = x['about']['类别'].replace(' ','')
else:
m_lb = '无类别'
dict1.setdefault(re.sub('\xa0+','',m_lb),[])
dict1[m_lb].append(x['name'])
filename = './file/术语类别.json'
with open(filename,'w') as fl:
json.dump(dict1, fl)
In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["jibing"]
dict1 = {}
list1 = []
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
if '疾病分类' in x['about'].keys():
m_lb = x['about']['疾病分类'].replace(' ','')
else:
m_lb = '无类别'
dict1.setdefault(re.sub('\xa0+','',m_lb),[])
dict1[m_lb].append(x['name'])
filename = './file/疾病类别.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["zhongcaoyao"]
dict1 = {}
mo = '等$'
mo2 = r'[,、;。]'
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
dict1.setdefault(x['name'],{})
if '别名' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['别名']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['别名'] = list1
if '功能' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['功能']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['功能'] = list1
if '主治' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
dict1[x['name']]['主治'] = s = x['about']['主治']
filename = './file/中草药主治功能统计.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["yaoji"]
dict1 = {}
mo = '等$'
mo2 = r'[,、;。]'
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
dict1.setdefault(x['name'],{})
if '功用' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['功用']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['功用'] = list1
if '主治' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
dict1[x['name']]['主治'] = s = x['about']['主治']
filename = './file/药剂主治功用统计.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import re
import pymongo
myclient = pymongo.MongoClient('mongodb://10.147.17.6:27017/')
mydb = myclient['dayi']
mycol = mydb["yaoshan"]
dict1 = {}
mo = '等$'
mo2 = r'[,、;。]'
for x in mycol.find({},{ "_id": 0,"name":1,"about":1 }):
dict1.setdefault(x['name'],{})
if '功效' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['功效']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['功效'] = list1
if '相关疾病' in x['about'].keys():
#dict1[x['name']].setdefault('主治',[])
s = x['about']['相关疾病']
s1 = re.sub(mo, '', s)
list1 = re.split(mo2,s1)
if '' in list1:
list1.remove('')
dict1[x['name']]['相关疾病'] = list1
filename = './file/药膳功能统计.json'
with open(filename,'w') as fl:
json.dump(dict1, fl) In [ ]:
import json
import openpyxl
import os,sys,shutil
file_name = 'file/中石化北海炼化2020年团体体检报告.xlsx'
wb = openpyxl.load_workbook(file_name)
sheet = wb.active
dict1 = {}
for n in range(1,sheet.max_row+1):
bh = sheet.cell(n,2).value
name = sheet.cell(n,3).value
xb = sheet.cell(n,4).value
nl = sheet.cell(n,5).value
bz = sheet.cell(n,7).value
dict1.setdefault(bh,{})
dict1[bh]['姓名'] = name
dict1[bh]['性别'] = xb
dict1[bh]['年龄'] = nl
dict1[bh].setdefault('病症',[])
dict1[bh]['病症'].append(bz.strip())
wb.close()
#print(dict1)
filename = 'file/中石化北海炼化2020年体检人员情况表.xlsx'
wb = openpyxl.Workbook()
sheet = wb.active
sheet['A1'] = '体检编号'
sheet['B1'] = '姓名'
sheet['C1'] = '性别'
sheet['D1'] = '年龄'
sheet['E1'] = '异常名称'
i =2
for k, v in dict1.items():
sheet[f'A{i}'] = k
sheet[f'B{i}'] = v['姓名']
sheet[f'C{i}'] = v['性别']
sheet[f'D{i}'] = v['年龄']
sheet[f'E{i}'] = ','.join(v['病症'])
i += 1
wb.save(filename)In [ ]:
import openpyxl
import json
filename = 'data/长岭全成绩.xlsx'
wb = openpyxl.load_workbook(filename)
sheet = wb.active
data1 =list(sheet.values)
del data1[0]
print(data1)
#for data in data1:
# print(data)
In [ ]:
from pyecharts.globals import CurrentConfig, NotebookType
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB
from pyecharts import options as opts
from pyecharts.charts import Bar,Line
import pyecharts.options as opts
from pyecharts.faker import Faker
import json
list_x = []
list_y = []
filename = 'data/17-21年一分一段表.json'
with open(filename,'r') as fl:
m_xx = json.load(fl)
dict1 =m_xx['2020']['z']
for i in sorted(dict1,reverse=True): #降序
list_x.append(i)
list_y.append(dict1[i]['num_person'])
#print(i,dict1[i]['num_person'])
bar = (
Bar()
.add_xaxis(list_x)
.add_yaxis("2020年一分一段表", list_y, category_gap=0, color=Faker.rand_color())
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-直方图"))
.render("bar_histogram2020.html")
# .set_global_opts(title_opts=opts.TitleOpts(title="运动步幅及步频", subtitle="户外运动"),)
)
#bar.load_javascript()In [ ]:
bar.render_notebook()In [ ]:
from pyecharts.globals import CurrentConfig, NotebookType
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB
from pyecharts import options as opts
from pyecharts.charts import Bar,Line
import pyecharts.options as opts
from pyecharts.faker import Faker
import json
x_2021 = []
y_2021 = []
x_2020 = []
y_2020 = []
filename = 'data/17-21年一分一段表.json'
with open(filename,'r') as fl:
m_xx = json.load(fl)
dict1 =m_xx['2021']['z']
for i in sorted(dict1,reverse=True): #降序
x_2021.append(i)
y_2021.append(dict1[i]['num_person'])
dict1 =m_xx['2020']['z']
for i in sorted(dict1,reverse=True): #降序
x_2021.append(i)
y_2021.append(dict1[i]['num_person'])
#print(i,dict1[i]['num_person'])
bar = (
Bar()
.add_xaxis(list_x)
.add_yaxis("人数", list_y, category_gap=0, color=Faker.rand_color())
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(title_opts=opts.TitleOpts(title="Bar-直方图"))
.render("bar_histogram.html")
In [18]:
from pyecharts.globals import CurrentConfig, NotebookType
import pyecharts.options as opts
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB
from pyecharts.charts import Radar
v1 = [[90, 100, 80, 76, 88, 95]]
v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]
bar =(
Radar(init_opts=opts.InitOpts())
.add_schema(
schema=[
opts.RadarIndicatorItem(name="销售(sales)", max_=100),
opts.RadarIndicatorItem(name="管理(Administration)", max_=100),
opts.RadarIndicatorItem(name="信息技术(Information Technology)", max_=100),
opts.RadarIndicatorItem(name="客服(Customer Support)", max_=100),
opts.RadarIndicatorItem(name="研发(Development)", max_=100),
opts.RadarIndicatorItem(name="市场(Marketing)", max_=100),
],
splitarea_opt=opts.SplitAreaOpts(
is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)
),
textstyle_opts=opts.TextStyleOpts(color="#aaa"),
)
.add(
series_name="预算分配(Allocated Budget)",
data=v1,
linestyle_opts=opts.LineStyleOpts(color="#CD0000"),
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
title_opts=opts.TitleOpts(title="基础雷达图"), legend_opts=opts.LegendOpts()
)
#.render("basic_radar_chart.html")
)
bar.load_javascript()Out [18]:
<pyecharts.render.display.Javascript at 0x7f28396390c0>
In [19]:
bar.render_notebook()Out [19]:
In [21]:
from pyecharts.globals import CurrentConfig, NotebookType
import pyecharts.options as opts
CurrentConfig.NOTEBOOK_TYPE = NotebookType.JUPYTER_LAB
from pyecharts.charts import Radar
from pyecharts.render import make_snapshot
from snapshot_phantomjs import snapshot
v1 = [[90, 100, 80, 76, 88, 95]]
v2 = [[5000, 14000, 28000, 31000, 42000, 21000]]
bar =(
Radar(init_opts=opts.InitOpts())
.add_schema(
schema=[
opts.RadarIndicatorItem(name="销售(sales)", max_=100),
opts.RadarIndicatorItem(name="管理(Administration)", max_=100),
opts.RadarIndicatorItem(name="信息技术(Information Technology)", max_=100),
opts.RadarIndicatorItem(name="客服(Customer Support)", max_=100),
opts.RadarIndicatorItem(name="研发(Development)", max_=100),
opts.RadarIndicatorItem(name="市场(Marketing)", max_=100),
],
splitarea_opt=opts.SplitAreaOpts(
is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)
),
textstyle_opts=opts.TextStyleOpts(color="#aaa"),
)
.add(
series_name="预算分配(Allocated Budget)",
data=v1,
linestyle_opts=opts.LineStyleOpts(color="#CD0000"),
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=False))
.set_global_opts(
title_opts=opts.TitleOpts(title="基础雷达图"), legend_opts=opts.LegendOpts()
)
#.render("basic_radar_chart.html")
)
make_snapshot(snapshot, bar.render(), "bar0.png")No phantomjs found in your PATH. Please install it!
[0;31m---------------------------------------------------------------------------[0m
[0;31mFileNotFoundError[0m Traceback (most recent call last)
File [0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:44[0m, in [0;36mchk_phantomjs[0;34m()[0m
[1;32m 43[0m [38;5;28;01mtry[39;00m:
[0;32m---> 44[0m phantomjs_version [38;5;241m=[39m [43msubprocess[49m[38;5;241;43m.[39;49m[43mcheck_output[49m[43m([49m
[1;32m 45[0m [43m [49m[43m[[49m[43mPHANTOMJS_EXEC[49m[43m,[49m[43m [49m[38;5;124;43m"[39;49m[38;5;124;43m--version[39;49m[38;5;124;43m"[39;49m[43m][49m[43m,[49m[43m [49m[43mshell[49m[38;5;241;43m=[39;49m[43mget_shell_flag[49m[43m([49m[43m)[49m
[1;32m 46[0m [43m [49m[43m)[49m
[1;32m 47[0m phantomjs_version [38;5;241m=[39m phantomjs_version[38;5;241m.[39mdecode([38;5;124m"[39m[38;5;124mutf-8[39m[38;5;124m"[39m)
File [0;32m/usr/lib/python3.10/subprocess.py:421[0m, in [0;36mcheck_output[0;34m(timeout, *popenargs, **kwargs)[0m
[1;32m 419[0m kwargs[[38;5;124m'[39m[38;5;124minput[39m[38;5;124m'[39m] [38;5;241m=[39m empty
[0;32m--> 421[0m [38;5;28;01mreturn[39;00m [43mrun[49m[43m([49m[38;5;241;43m*[39;49m[43mpopenargs[49m[43m,[49m[43m [49m[43mstdout[49m[38;5;241;43m=[39;49m[43mPIPE[49m[43m,[49m[43m [49m[43mtimeout[49m[38;5;241;43m=[39;49m[43mtimeout[49m[43m,[49m[43m [49m[43mcheck[49m[38;5;241;43m=[39;49m[38;5;28;43;01mTrue[39;49;00m[43m,[49m
[1;32m 422[0m [43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m[38;5;241m.[39mstdout
File [0;32m/usr/lib/python3.10/subprocess.py:503[0m, in [0;36mrun[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)[0m
[1;32m 501[0m kwargs[[38;5;124m'[39m[38;5;124mstderr[39m[38;5;124m'[39m] [38;5;241m=[39m PIPE
[0;32m--> 503[0m [38;5;28;01mwith[39;00m [43mPopen[49m[43m([49m[38;5;241;43m*[39;49m[43mpopenargs[49m[43m,[49m[43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m)[49m [38;5;28;01mas[39;00m process:
[1;32m 504[0m [38;5;28;01mtry[39;00m:
File [0;32m/usr/lib/python3.10/subprocess.py:971[0m, in [0;36mPopen.__init__[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)[0m
[1;32m 968[0m [38;5;28mself[39m[38;5;241m.[39mstderr [38;5;241m=[39m io[38;5;241m.[39mTextIOWrapper([38;5;28mself[39m[38;5;241m.[39mstderr,
[1;32m 969[0m encoding[38;5;241m=[39mencoding, errors[38;5;241m=[39merrors)
[0;32m--> 971[0m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43m_execute_child[49m[43m([49m[43margs[49m[43m,[49m[43m [49m[43mexecutable[49m[43m,[49m[43m [49m[43mpreexec_fn[49m[43m,[49m[43m [49m[43mclose_fds[49m[43m,[49m
[1;32m 972[0m [43m [49m[43mpass_fds[49m[43m,[49m[43m [49m[43mcwd[49m[43m,[49m[43m [49m[43menv[49m[43m,[49m
[1;32m 973[0m [43m [49m[43mstartupinfo[49m[43m,[49m[43m [49m[43mcreationflags[49m[43m,[49m[43m [49m[43mshell[49m[43m,[49m
[1;32m 974[0m [43m [49m[43mp2cread[49m[43m,[49m[43m [49m[43mp2cwrite[49m[43m,[49m
[1;32m 975[0m [43m [49m[43mc2pread[49m[43m,[49m[43m [49m[43mc2pwrite[49m[43m,[49m
[1;32m 976[0m [43m [49m[43merrread[49m[43m,[49m[43m [49m[43merrwrite[49m[43m,[49m
[1;32m 977[0m [43m [49m[43mrestore_signals[49m[43m,[49m
[1;32m 978[0m [43m [49m[43mgid[49m[43m,[49m[43m [49m[43mgids[49m[43m,[49m[43m [49m[43muid[49m[43m,[49m[43m [49m[43mumask[49m[43m,[49m
[1;32m 979[0m [43m [49m[43mstart_new_session[49m[43m)[49m
[1;32m 980[0m [38;5;28;01mexcept[39;00m:
[1;32m 981[0m [38;5;66;03m# Cleanup if the child failed starting.[39;00m
File [0;32m/usr/lib/python3.10/subprocess.py:1863[0m, in [0;36mPopen._execute_child[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)[0m
[1;32m 1862[0m err_msg [38;5;241m=[39m os[38;5;241m.[39mstrerror(errno_num)
[0;32m-> 1863[0m [38;5;28;01mraise[39;00m child_exception_type(errno_num, err_msg, err_filename)
[1;32m 1864[0m [38;5;28;01mraise[39;00m child_exception_type(err_msg)
[0;31mFileNotFoundError[0m: [Errno 2] No such file or directory: 'phantomjs'
During handling of the above exception, another exception occurred:
[0;31mSystemExit[0m Traceback (most recent call last)
[0;31m[... skipping hidden 1 frame][0m
Cell [0;32mIn[21], line 41[0m
[1;32m 12[0m bar [38;5;241m=[39m(
[1;32m 13[0m Radar(init_opts[38;5;241m=[39mopts[38;5;241m.[39mInitOpts())
[1;32m 14[0m [38;5;241m.[39madd_schema(
[0;32m (...)[0m
[1;32m 39[0m
[1;32m 40[0m )
[0;32m---> 41[0m [43mmake_snapshot[49m[43m([49m[43msnapshot[49m[43m,[49m[43m [49m[43mbar[49m[38;5;241;43m.[39;49m[43mrender[49m[43m([49m[43m)[49m[43m,[49m[43m [49m[38;5;124;43m"[39;49m[38;5;124;43mbar0.png[39;49m[38;5;124;43m"[39;49m[43m)[49m
File [0;32m~/data/lib/python3.10/site-packages/pyecharts/render/snapshot.py:32[0m, in [0;36mmake_snapshot[0;34m(engine, file_name, output_name, delay, pixel_ratio, is_remove_html, **kwargs)[0m
[1;32m 30[0m file_type [38;5;241m=[39m output_name[38;5;241m.[39msplit([38;5;124m"[39m[38;5;124m.[39m[38;5;124m"[39m)[[38;5;241m-[39m[38;5;241m1[39m]
[0;32m---> 32[0m content [38;5;241m=[39m [43mengine[49m[38;5;241;43m.[39;49m[43mmake_snapshot[49m[43m([49m
[1;32m 33[0m [43m [49m[43mhtml_path[49m[38;5;241;43m=[39;49m[43mfile_name[49m[43m,[49m
[1;32m 34[0m [43m [49m[43mfile_type[49m[38;5;241;43m=[39;49m[43mfile_type[49m[43m,[49m
[1;32m 35[0m [43m [49m[43mdelay[49m[38;5;241;43m=[39;49m[43mdelay[49m[43m,[49m
[1;32m 36[0m [43m [49m[43mpixel_ratio[49m[38;5;241;43m=[39;49m[43mpixel_ratio[49m[43m,[49m
[1;32m 37[0m [43m [49m[38;5;241;43m*[39;49m[38;5;241;43m*[39;49m[43mkwargs[49m[43m,[49m
[1;32m 38[0m [43m[49m[43m)[49m
[1;32m 39[0m [38;5;28;01mif[39;00m file_type [38;5;129;01min[39;00m [SVG_FORMAT, B64_FORMAT]:
File [0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:15[0m, in [0;36mmake_snapshot[0;34m(html_path, file_type, delay, pixel_ratio, **_)[0m
[1;32m 12[0m [38;5;28;01mdef[39;00m [38;5;21mmake_snapshot[39m(
[1;32m 13[0m html_path: [38;5;28mstr[39m, file_type: [38;5;28mstr[39m, delay: [38;5;28mint[39m [38;5;241m=[39m [38;5;241m2[39m, pixel_ratio: [38;5;28mint[39m [38;5;241m=[39m [38;5;241m2[39m, [38;5;241m*[39m[38;5;241m*[39m_
[1;32m 14[0m ):
[0;32m---> 15[0m [43mchk_phantomjs[49m[43m([49m[43m)[49m
[1;32m 16[0m logger[38;5;241m.[39minfo([38;5;124m"[39m[38;5;124mGenerating file ...[39m[38;5;124m"[39m)
File [0;32m~/data/lib/python3.10/site-packages/snapshot_phantomjs/snapshot.py:51[0m, in [0;36mchk_phantomjs[0;34m()[0m
[1;32m 50[0m logger[38;5;241m.[39mwarning([38;5;124m"[39m[38;5;124mNo phantomjs found in your PATH. Please install it![39m[38;5;124m"[39m)
[0;32m---> 51[0m [43msys[49m[38;5;241;43m.[39;49m[43mexit[49m[43m([49m[38;5;241;43m1[39;49m[43m)[49m
[0;31mSystemExit[0m: 1
During handling of the above exception, another exception occurred:
[0;31mAttributeError[0m Traceback (most recent call last)
[0;31m[... skipping hidden 1 frame][0m
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2097[0m, in [0;36mInteractiveShell.showtraceback[0;34m(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)[0m
[1;32m 2094[0m [38;5;28;01mif[39;00m exception_only:
[1;32m 2095[0m stb [38;5;241m=[39m [[38;5;124m'[39m[38;5;124mAn exception has occurred, use [39m[38;5;124m%[39m[38;5;124mtb to see [39m[38;5;124m'[39m
[1;32m 2096[0m [38;5;124m'[39m[38;5;124mthe full traceback.[39m[38;5;130;01m\n[39;00m[38;5;124m'[39m]
[0;32m-> 2097[0m stb[38;5;241m.[39mextend([38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mInteractiveTB[49m[38;5;241;43m.[39;49m[43mget_exception_only[49m[43m([49m[43metype[49m[43m,[49m
[1;32m 2098[0m [43m [49m[43mvalue[49m[43m)[49m)
[1;32m 2099[0m [38;5;28;01melse[39;00m:
[1;32m 2101[0m [38;5;28;01mdef[39;00m [38;5;21mcontains_exceptiongroup[39m(val):
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:710[0m, in [0;36mListTB.get_exception_only[0;34m(self, etype, value)[0m
[1;32m 702[0m [38;5;28;01mdef[39;00m [38;5;21mget_exception_only[39m([38;5;28mself[39m, etype, value):
[1;32m 703[0m [38;5;250m [39m[38;5;124;03m"""Only print the exception type and message, without a traceback.[39;00m
[1;32m 704[0m
[1;32m 705[0m [38;5;124;03m Parameters[39;00m
[0;32m (...)[0m
[1;32m 708[0m [38;5;124;03m value : exception value[39;00m
[1;32m 709[0m [38;5;124;03m """[39;00m
[0;32m--> 710[0m [38;5;28;01mreturn[39;00m [43mListTB[49m[38;5;241;43m.[39;49m[43mstructured_traceback[49m[43m([49m[38;5;28;43mself[39;49m[43m,[49m[43m [49m[43metype[49m[43m,[49m[43m [49m[43mvalue[49m[43m)[49m
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:568[0m, in [0;36mListTB.structured_traceback[0;34m(self, etype, evalue, etb, tb_offset, context)[0m
[1;32m 565[0m chained_exc_ids[38;5;241m.[39madd([38;5;28mid[39m(exception[[38;5;241m1[39m]))
[1;32m 566[0m chained_exceptions_tb_offset [38;5;241m=[39m [38;5;241m0[39m
[1;32m 567[0m out_list [38;5;241m=[39m (
[0;32m--> 568[0m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mstructured_traceback[49m[43m([49m
[1;32m 569[0m [43m [49m[43metype[49m[43m,[49m
[1;32m 570[0m [43m [49m[43mevalue[49m[43m,[49m
[1;32m 571[0m [43m [49m[43m([49m[43metb[49m[43m,[49m[43m [49m[43mchained_exc_ids[49m[43m)[49m[43m,[49m[43m [49m[38;5;66;43;03m# type: ignore[39;49;00m
[1;32m 572[0m [43m [49m[43mchained_exceptions_tb_offset[49m[43m,[49m
[1;32m 573[0m [43m [49m[43mcontext[49m[43m,[49m
[1;32m 574[0m [43m [49m[43m)[49m
[1;32m 575[0m [38;5;241m+[39m chained_exception_message
[1;32m 576[0m [38;5;241m+[39m out_list)
[1;32m 578[0m [38;5;28;01mreturn[39;00m out_list
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1435[0m, in [0;36mAutoFormattedTB.structured_traceback[0;34m(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)[0m
[1;32m 1433[0m [38;5;28;01melse[39;00m:
[1;32m 1434[0m [38;5;28mself[39m[38;5;241m.[39mtb [38;5;241m=[39m etb
[0;32m-> 1435[0m [38;5;28;01mreturn[39;00m [43mFormattedTB[49m[38;5;241;43m.[39;49m[43mstructured_traceback[49m[43m([49m
[1;32m 1436[0m [43m [49m[38;5;28;43mself[39;49m[43m,[49m[43m [49m[43metype[49m[43m,[49m[43m [49m[43mevalue[49m[43m,[49m[43m [49m[43metb[49m[43m,[49m[43m [49m[43mtb_offset[49m[43m,[49m[43m [49m[43mnumber_of_lines_of_context[49m
[1;32m 1437[0m [43m[49m[43m)[49m
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1326[0m, in [0;36mFormattedTB.structured_traceback[0;34m(self, etype, value, tb, tb_offset, number_of_lines_of_context)[0m
[1;32m 1323[0m mode [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mmode
[1;32m 1324[0m [38;5;28;01mif[39;00m mode [38;5;129;01min[39;00m [38;5;28mself[39m[38;5;241m.[39mverbose_modes:
[1;32m 1325[0m [38;5;66;03m# Verbose modes need a full traceback[39;00m
[0;32m-> 1326[0m [38;5;28;01mreturn[39;00m [43mVerboseTB[49m[38;5;241;43m.[39;49m[43mstructured_traceback[49m[43m([49m
[1;32m 1327[0m [43m [49m[38;5;28;43mself[39;49m[43m,[49m[43m [49m[43metype[49m[43m,[49m[43m [49m[43mvalue[49m[43m,[49m[43m [49m[43mtb[49m[43m,[49m[43m [49m[43mtb_offset[49m[43m,[49m[43m [49m[43mnumber_of_lines_of_context[49m
[1;32m 1328[0m [43m [49m[43m)[49m
[1;32m 1329[0m [38;5;28;01melif[39;00m mode [38;5;241m==[39m [38;5;124m'[39m[38;5;124mMinimal[39m[38;5;124m'[39m:
[1;32m 1330[0m [38;5;28;01mreturn[39;00m ListTB[38;5;241m.[39mget_exception_only([38;5;28mself[39m, etype, value)
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1173[0m, in [0;36mVerboseTB.structured_traceback[0;34m(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)[0m
[1;32m 1164[0m [38;5;28;01mdef[39;00m [38;5;21mstructured_traceback[39m(
[1;32m 1165[0m [38;5;28mself[39m,
[1;32m 1166[0m etype: [38;5;28mtype[39m,
[0;32m (...)[0m
[1;32m 1170[0m number_of_lines_of_context: [38;5;28mint[39m [38;5;241m=[39m [38;5;241m5[39m,
[1;32m 1171[0m ):
[1;32m 1172[0m [38;5;250m [39m[38;5;124;03m"""Return a nice text document describing the traceback."""[39;00m
[0;32m-> 1173[0m formatted_exception [38;5;241m=[39m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mformat_exception_as_a_whole[49m[43m([49m[43metype[49m[43m,[49m[43m [49m[43mevalue[49m[43m,[49m[43m [49m[43metb[49m[43m,[49m[43m [49m[43mnumber_of_lines_of_context[49m[43m,[49m
[1;32m 1174[0m [43m [49m[43mtb_offset[49m[43m)[49m
[1;32m 1176[0m colors [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mColors [38;5;66;03m# just a shorthand + quicker name lookup[39;00m
[1;32m 1177[0m colorsnormal [38;5;241m=[39m colors[38;5;241m.[39mNormal [38;5;66;03m# used a lot[39;00m
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1063[0m, in [0;36mVerboseTB.format_exception_as_a_whole[0;34m(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)[0m
[1;32m 1060[0m [38;5;28;01massert[39;00m [38;5;28misinstance[39m(tb_offset, [38;5;28mint[39m)
[1;32m 1061[0m head [38;5;241m=[39m [38;5;28mself[39m[38;5;241m.[39mprepare_header([38;5;28mstr[39m(etype), [38;5;28mself[39m[38;5;241m.[39mlong_header)
[1;32m 1062[0m records [38;5;241m=[39m (
[0;32m-> 1063[0m [38;5;28;43mself[39;49m[38;5;241;43m.[39;49m[43mget_records[49m[43m([49m[43metb[49m[43m,[49m[43m [49m[43mnumber_of_lines_of_context[49m[43m,[49m[43m [49m[43mtb_offset[49m[43m)[49m [38;5;28;01mif[39;00m etb [38;5;28;01melse[39;00m []
[1;32m 1064[0m )
[1;32m 1066[0m frames [38;5;241m=[39m []
[1;32m 1067[0m skipped [38;5;241m=[39m [38;5;241m0[39m
File [0;32m~/data/lib/python3.10/site-packages/IPython/core/ultratb.py:1131[0m, in [0;36mVerboseTB.get_records[0;34m(self, etb, number_of_lines_of_context, tb_offset)[0m
[1;32m 1129[0m [38;5;28;01mwhile[39;00m cf [38;5;129;01mis[39;00m [38;5;129;01mnot[39;00m [38;5;28;01mNone[39;00m:
[1;32m 1130[0m [38;5;28;01mtry[39;00m:
[0;32m-> 1131[0m mod [38;5;241m=[39m inspect[38;5;241m.[39mgetmodule([43mcf[49m[38;5;241;43m.[39;49m[43mtb_frame[49m)
[1;32m 1132[0m [38;5;28;01mif[39;00m mod [38;5;129;01mis[39;00m [38;5;129;01mnot[39;00m [38;5;28;01mNone[39;00m:
[1;32m 1133[0m mod_name [38;5;241m=[39m mod[38;5;241m.[39m[38;5;18m__name__[39m
[0;31mAttributeError[0m: 'tuple' object has no attribute 'tb_frame'In [27]:
import pygal
radar_chart = pygal.Radar()
radar_chart.title = 'V8 benchmark results'
radar_chart.x_labels = ['Richards', 'DeltaBlue', 'Crypto', 'RayTrace', 'EarleyBoyer', 'RegExp', 'Splay', 'NavierStokes']
radar_chart.add('Chrome', [6395, 8212, 7520, 7218, 12464, 1660, 2123, 8607])
radar_chart.render_to_png('chart.png')In [ ]: