6月6日是全国爱眼日,我国现有约500万盲人,占总人口的0.4%,是世界上盲和视力损伤严重的国家之一,随着经济社会的发展和人口结构的老龄化,非传染性的眼科疾病成为我国致盲的主要原因。小学生开始戴眼镜的比比皆是,高中以前没戴眼镜的屈指可数,大学之后,少了高中的学习压力也有很多朋友视力节节下降,并得一些难愈的从未了解过的眼科疾病。现代人的生活方式足以见得普通人对用眼护眼还不够重视。高中开始在红丹丹心目影院当志愿者,寒假参与了一次与盲人朋友一起听电影的活动,更觉得应该珍惜现有的光明。作为人体的五官之一,眼睛承载了个体与世界之间的诸多连接和生活的体验感,眼科应该受到更多的重视。
这次研究爬取的网站是39健康网的眼科疾病网页,鉴于信息量太大,采用等距抽样(Systematic Sampling)的方法,只抽取编号尾号为0的眼科疾病基本信息。其中基本信息包括:疾病名称、别名、是否医保、发病部位、传染性、治疗方法、治愈率、多发人群、典型症状、临床检查、并发症、常用药品、综述内容、症状起因、诊断详述、检查鉴别。
import scrapy
class YankeItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
# 疾病名称
mingcheng = scrapy.Field()
# 别名
bieming = scrapy.Field()
# 是否医保
yibao = scrapy.Field()
# 发病部位
fabingbuwei = scrapy.Field()
# 传染性
chuanranxing = scrapy.Field()
# 治疗方法
zhiliaofangfa = scrapy.Field()
# 治愈率
zhiyulv = scrapy.Field()
# 多发人群
duofarenqun = scrapy.Field()
# 典型症状
dianxingzhengzhuang = scrapy.Field()
# 临床检查
linchuangjiancha = scrapy.Field()
# 并发症
bingfazheng = scrapy.Field()
# 常用药品
changyongyaopin = scrapy.Field()
# 综述内容
neirong = scrapy.Field()
# 症状起因
zhengzhuangqiyin = scrapy.Field()
# 诊断详述
zhenduanxiangshu = scrapy.Field()
# 检查鉴别
jianchajianbie = scrapy.Field()
pass
from scrapy import signals
from scrapy.downloadermiddlewares.useragent import UserAgentMiddleware
import random
class TestuaMiddleware(object): #轮换代理agent
def __init__(self):
self.user_agent_list = [
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1" \
"Mozilla/5.0 (X11; CrOS i686 2268.111.0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1090.0 Safari/536.6", \
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/19.77.34.5 Safari/537.1", \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.9 Safari/536.5", \
"Mozilla/5.0 (Windows NT 6.0) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.36 Safari/536.5", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1063.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1062.0 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.1 Safari/536.3", \
"Mozilla/5.0 (Windows NT 6.2) AppleWebKit/536.3 (KHTML, like Gecko) Chrome/19.0.1061.0 Safari/536.3", \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24", \
"Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.24 (KHTML, like Gecko) Chrome/19.0.1055.1 Safari/535.24"
]
def process_request(self, request, spider):
request.headers['User-Agent'] = random.choice(self.user_agent_list)
# for more user agent strings,you can find it in http://www.useragentstring.com/pages/useragentstring.php
class ScrapyspiderSpiderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the spider middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_spider_input(self, response, spider):
# Called for each response that goes through the spider
# middleware and into the spider.
# Should return None or raise an exception.
return None
def process_spider_output(self, response, result, spider):
# Called with the results returned from the Spider, after
# it has processed the response.
# Must return an iterable of Request, dict or Item objects.
for i in result:
yield i
def process_spider_exception(self, response, exception, spider):
# Called when a spider or process_spider_input() method
# (from other spider middleware) raises an exception.
# Should return either None or an iterable of Request, dict
# or Item objects.
pass
def process_start_requests(self, start_requests, spider):
# Called with the start requests of the spider, and works
# similarly to the process_spider_output() method, except
# that it doesn’t have a response associated.
# Must return only requests (not items).
for r in start_requests:
yield r
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
class ScrapyspiderDownloaderMiddleware(object):
# Not all methods need to be defined. If a method is not defined,
# scrapy acts as if the downloader middleware does not modify the
# passed objects.
@classmethod
def from_crawler(cls, crawler):
# This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
def process_request(self, request, spider):
# Called for each request that goes through the downloader
# middleware.
# Must either:
# - return None: continue processing this request
# - or return a Response object
# - or return a Request object
# - or raise IgnoreRequest: process_exception() methods of
# installed downloader middleware will be called
return None
def process_response(self, request, response, spider):
# Called with the response returned from the downloader.
# Must either;
# - return a Response object
# - return a Request object
# - or raise IgnoreRequest
return response
def process_exception(self, request, exception, spider):
# Called when a download handler or a process_request()
# (from other downloader middleware) raises an exception.
# Must either:
# - return None: continue processing this exception
# - return a Response object: stops process_exception() chain
# - return a Request object: stops process_exception() chain
pass
def spider_opened(self, spider):
spider.logger.info('Spider opened: %s' % spider.name)
import csv
class ScrapyspiderPipeline(object):
def __init__(self):
self.f = open('result.csv', 'a', newline='')
self.fieldnames = ['bieming', 'bingfazheng', 'changyongyaopin', 'chuanranxing', 'dianxingzhengzhuang', 'duofarenqun', 'fabingbuwei', 'jianchajianbie', 'linchuangjiancha', 'mingcheng', 'neirong', 'yibao', 'zhenduanxiangshu', 'zhengzhuangqiyin', 'zhiliaofangfa', 'zhiyulv']
self.writer = csv.DictWriter(self.f, fieldnames=self.fieldnames)
self.writer.writeheader()
def process_item(self, item, spider):
self.writer.writerow(item)
return item
def open_spider(self,spider):
pass
def close_spider(self,spider):
self.f.close()
BOT_NAME = 'scrapyspider'
SPIDER_MODULES = ['scrapyspider.spiders']
NEWSPIDER_MODULE = 'scrapyspider.spiders'
DOWNLOADER_MIDDLEWARES = {
'scrapyspider.middlewares.TestuaMiddleware': 300 # 代理池
}
# Crawl responsibly by identifying yourself (and your website) on the user-agent
USER_AGENT = 'scrapyspider (+http://www.yourdomain.com)'
# Obey robots.txt rules
ROBOTSTXT_OBEY = False
HTTPERROR_ALLOWED_CODES = [404]
FEED_EXPORT_ENCODING = 'utf-8-sig'
ITEM_PIPELINES = {
'scrapyspider.pipelines.ScrapyspiderPipeline': 300,
}
从优先级队列中获取request对象,交给engine。
engine将request对象交给下载器下载,期间会通过downloadmiddleware的process_request方法。
下载器完成下载,获得response对象,将该对象交给engine,期间会经过downloadmiddleware的process_response()方法。
engine将获得的response对象交给spider进行解析,期间会经过spidermiddleware的process_spider_input()的方法。
spider解析下载器下下来的response,返回item或是links(url)。
item或者link经过spidermiddleware的process_spider_out()方法,交给engine。
engine将item交给item pipeline ,将links交给调度器。
在调度器中,先将requests对象利用scrapy内置的指纹函数生成一个指纹。
如果requests对象中的don’t filter参数设置为False,并且该requests对象的指纹不在信息指纹的队列中,那么就把该request对象放到优先级队列中。
循环以上操作
进入39健康网>进入疾病百科>疾病症状>眼科,收集网页中各个疾病的超链接地址存入url,循环进入具体疾病页面。
在疾病页面收集各个基本信息文本存入item,收集典型症状超链接存入url,循环进入各个症状页面。
进入典型症状综述页面收集文本信息,依次跳转至下一页面症状起因、诊断详述、检查鉴别页面收集文本信息。
数据的预处理在excel中进行,因为数据过多,且文本信息较大,再明确了主题和研究方向之后,进一步将数据进行筛查。
关于变量标签——主要删除了不易进行定量统计的描述性内容:临床检查、综述内容、症状起因、诊断详述、检查鉴别。与研究方向关联性较弱的内容:别名、发病部位、是否医保、常用药品。
关于统计值——
# import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import read_csv
import csv
result_df = pd.read_csv('result.csv',encoding='gbk')
print("数据共有{}个样本".format(len(result_df)))
print("数据形式如下:")
result_df.head()
#yankeFile = open(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',encoding='gbk')
#yankeReader = csv.reader(yankeFile)
#for row in yankeReader:
# print(" ".join(row))
数据共有660个样本
数据形式如下:
bingfazheng | chuanranxing | dianxingzhengzhuang | duofarenqun | mingcheng | zhiliaofangfa | zhiyulv | |
---|---|---|---|---|---|---|---|
0 | [] | ['无传染性'] | ['视力障碍', '视野缺损', '视网膜脱离'] | ['中老年人群'] | ['视网膜脱落'] | ['中医药物治疗'] | [10%] |
1 | [] | ['无传染性'] | ['视力障碍', '视野缺损', '视网膜脱离'] | ['中老年人群'] | ['视网膜脱落'] | ['中医药物治疗'] | [10%] |
2 | [] | ['无传染性'] | ['目垢增多', '眼痛', '视力障碍'] | ['中老年人群'] | ['泪腺多形性腺癌'] | ['手术治疗、放射治疗、药物治...'] | [10%] |
3 | [] | ['无传染性'] | ['目垢增多', '眼痛', '视力障碍'] | ['中老年人群'] | ['泪腺多形性腺癌'] | ['手术治疗、放射治疗、药物治...'] | [10%] |
4 | [] | ['无传染性'] | ['视力障碍', '偏瘫', '复视'] | ['中老年人群'] | ['巨细胞动脉炎性巩膜炎'] | ['药物治疗'] | [10%] |
for i in range(0,len(result_df)) :
result_df['chuanranxing'][i] = result_df['chuanranxing'][i][2:-2]
result_df['dianxingzhengzhuang'][i] = result_df['dianxingzhengzhuang'][i][2:-2]
result_df['duofarenqun'][i] = result_df['duofarenqun'][i][2:-2]
result_df['mingcheng'][i] = result_df['mingcheng'][i][2:-2]
result_df['zhiliaofangfa'][i] = result_df['zhiliaofangfa'][i][2:-2]
result_df['zhiyulv'][i] = result_df['zhiyulv'][i][1:-1]
result_df['bingfazheng'][i] = result_df['bingfazheng'][i][1:-1]
result_df.head()
bingfazheng | chuanranxing | dianxingzhengzhuang | duofarenqun | mingcheng | zhiliaofangfa | zhiyulv | |
---|---|---|---|---|---|---|---|
0 | 无传染性 | 视力障碍', '视野缺损', '视网膜脱离 | 中老年人群 | 视网膜脱落 | 中医药物治疗 | 10% | |
1 | 无传染性 | 视力障碍', '视野缺损', '视网膜脱离 | 中老年人群 | 视网膜脱落 | 中医药物治疗 | 10% | |
2 | 无传染性 | 目垢增多', '眼痛', '视力障碍 | 中老年人群 | 泪腺多形性腺癌 | 手术治疗、放射治疗、药物治... | 10% | |
3 | 无传染性 | 目垢增多', '眼痛', '视力障碍 | 中老年人群 | 泪腺多形性腺癌 | 手术治疗、放射治疗、药物治... | 10% | |
4 | 无传染性 | 视力障碍', '偏瘫', '复视 | 中老年人群 | 巨细胞动脉炎性巩膜炎 | 药物治疗 | 10% |
result_df.info()
RangeIndex: 660 entries, 0 to 659
Data columns (total 7 columns):
bingfazheng 660 non-null object
chuanranxing 660 non-null object
dianxingzhengzhuang 660 non-null object
duofarenqun 660 non-null object
mingcheng 660 non-null object
zhiliaofangfa 660 non-null object
zhiyulv 660 non-null object
dtypes: object(7)
memory usage: 36.2+ KB
result_df['bingfazheng']
0
1
2
3
4
...
655 '虹膜睫状体炎', '青光眼'
656 '虹膜睫状体炎', '青光眼'
657 '角膜炎'
658 '脑血管瘤', '眼底血管样条纹', '玻璃体及视网膜脱离手术所致青光眼'
659 '脑血管瘤', '眼底血管样条纹', '玻璃体及视网膜脱离手术所致青光眼'
Name: bingfazheng, Length: 660, dtype: object
result_df['zhiyulv']
0 0.1
1 0.1
2 0.1
3 0.1
4 0.1
...
655 91.2%
656 91.2%
657 98%
658 90%
659 90%
Name: zhiyulv, Length: 660, dtype: object
result_df['duofarenqun'].unique()
array(['中老年人群', '婴幼儿', '眼科手术病人', '性活跃人群多见', '所有人群', '青少年', '胚胎期', '儿童',
'产妇'], dtype=object)
a = result_df[result_df['duofarenqun'] == '中老年人群']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 105
chuanranxing 105
dianxingzhengzhuang 105
duofarenqun 105
mingcheng 105
zhiliaofangfa 105
zhiyulv 105
dtype: int64
bingfazheng 3
chuanranxing 3
dianxingzhengzhuang 3
duofarenqun 3
mingcheng 3
zhiliaofangfa 3
zhiyulv 3
dtype: int64
a = result_df[result_df['duofarenqun'] == '婴幼儿']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 30
chuanranxing 30
dianxingzhengzhuang 30
duofarenqun 30
mingcheng 30
zhiliaofangfa 30
zhiyulv 30
dtype: int64
bingfazheng 2
chuanranxing 2
dianxingzhengzhuang 2
duofarenqun 2
mingcheng 2
zhiliaofangfa 2
zhiyulv 2
dtype: int64
a = result_df[result_df['duofarenqun'] == '眼科手术病人']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 6
chuanranxing 6
dianxingzhengzhuang 6
duofarenqun 6
mingcheng 6
zhiliaofangfa 6
zhiyulv 6
dtype: int64
bingfazheng 0
chuanranxing 0
dianxingzhengzhuang 0
duofarenqun 0
mingcheng 0
zhiliaofangfa 0
zhiyulv 0
dtype: int64
a = result_df[result_df['duofarenqun'] == '性活跃人群多见']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 0
chuanranxing 0
dianxingzhengzhuang 0
duofarenqun 0
mingcheng 0
zhiliaofangfa 0
zhiyulv 0
dtype: int64
bingfazheng 2
chuanranxing 2
dianxingzhengzhuang 2
duofarenqun 2
mingcheng 2
zhiliaofangfa 2
zhiyulv 2
dtype: int64
a = result_df[result_df['duofarenqun'] == '青少年']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 42
chuanranxing 42
dianxingzhengzhuang 42
duofarenqun 42
mingcheng 42
zhiliaofangfa 42
zhiyulv 42
dtype: int64
bingfazheng 6
chuanranxing 6
dianxingzhengzhuang 6
duofarenqun 6
mingcheng 6
zhiliaofangfa 6
zhiyulv 6
dtype: int64
a = result_df[result_df['duofarenqun'] == '胚胎期']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 2
chuanranxing 2
dianxingzhengzhuang 2
duofarenqun 2
mingcheng 2
zhiliaofangfa 2
zhiyulv 2
dtype: int64
bingfazheng 0
chuanranxing 0
dianxingzhengzhuang 0
duofarenqun 0
mingcheng 0
zhiliaofangfa 0
zhiyulv 0
dtype: int64
a = result_df[result_df['duofarenqun'] == '儿童']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 46
chuanranxing 46
dianxingzhengzhuang 46
duofarenqun 46
mingcheng 46
zhiliaofangfa 46
zhiyulv 46
dtype: int64
bingfazheng 4
chuanranxing 4
dianxingzhengzhuang 4
duofarenqun 4
mingcheng 4
zhiliaofangfa 4
zhiyulv 4
dtype: int64
a = result_df[result_df['duofarenqun'] == '产妇']
print(a[a['chuanranxing'] == '无传染性'].count())
print(a[a['chuanranxing'] == '有传染性'].count())
bingfazheng 2
chuanranxing 2
dianxingzhengzhuang 2
duofarenqun 2
mingcheng 2
zhiliaofangfa 2
zhiyulv 2
dtype: int64
bingfazheng 0
chuanranxing 0
dianxingzhengzhuang 0
duofarenqun 0
mingcheng 0
zhiliaofangfa 0
zhiyulv 0
dtype: int64
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号
plt.figure(1, figsize=(10, 10))
name_list = ['中老年人群','婴幼儿','眼科手术病人','性活跃人群多见','所有人群','青少年', '胚胎期', '儿童','产妇'] #人群
num_list = [105,30,6,0,376,42,2,46,2] #无传染性数量
num_list1 = [3,2,0,2,34,6,0,4,0] #有传染性数量
plt.bar(range(len(num_list)), num_list, label='无传染性人数',fc = 'y')
plt.bar(range(len(num_list)), num_list1, bottom=num_list, label='有传染性人数',fc = 'r')
plt.xlabel("人群种类",fontsize = 15) # 指定x轴描述信息
plt.ylabel("感染情况人数",fontsize = 15) # 指定y轴描述信息
plt.title("不同种类人群是否具有感染能力人数比较",fontsize = 20) # 指定图表描述信息
plt.legend()
plt.xticks(idx, name_list)
plt.xticks(fontsize = 10)
plt.yticks(fontsize = 15)
plt.show()
传染性疾病是否会对某类人群有特殊偏好?
老年人还是青年人更易获得可传染的眼科疾病?
带着对以上问题的好奇,通过统计各类人群的感染病例数量和感染病例的有无传染性状况,绘制了以上柱状图。
单比较每个年龄区间的人群患传染性疾病的概率可以看出,青少年患传染性眼科疾病的概率更大,青少年还需加强用眼卫生,降低患病概率。
我们还可以得出有传染性疾病的特殊人群特征以青少年为主,儿童其次,然后是中老年人群。由于y轴是数量不是概率,故能得出青少年患有传染性的概率相较中老年人群还是很多的,因其整体患病数量小于中老年人群,患传染性疾病却多于中老年人群。这也让我们对抵抗能力较差的中老年人群舒一口气。
儿童和婴幼儿的抵抗力也较弱,其患有传染性疾病的概率相较青少年低,但高于中老年人群。故此也需要更加重视儿童的用眼卫生,控制儿童的疲劳用眼时间,减少他们对电子产品的依赖性,树立正确的眼部卫生观念,不能用手揉眼睛等。
其他不以年龄划分的人群特征的主要有眼科手术病人群和性活跃人群。说明特殊病症可能会通过性传播,这对于国内尚未成熟的性教育也有很高的要求,不健康的性行为更有可能带来的不只是性疾病的伤害。手术时的操作风险也有可能带来新的疾病,怎样把握防控好风险也是我们要思考的事情。
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import read_csv
#数据
data=open(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',encoding='gbk')
data=read_csv(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',encoding='gbk')
print(data.duofarenqun.value_counts())
print(data.chuanranxing.value_counts())
['所有人群'] 410
['中老年人群'] 108
['儿童'] 50
['青少年'] 48
['婴幼儿'] 32
['眼科手术病人'] 6
['产妇'] 2
['胚胎期'] 2
['性活跃人群多见'] 2
Name: duofarenqun, dtype: int64
['无传染性'] 609
['有传染性'] 51
Name: chuanranxing, dtype: int64
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from pandas import read_csv
#数据
data=open(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',encoding='gbk')
data=read_csv(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',encoding='gbk')
print(data.duofarenqun.value_counts())
print(data.chuanranxing.value_counts())
#Pie chart, where the slices will be ordered and plotted counter-clockwise:
labels = '所有人群','中老年人群','儿童','青少年','婴幼儿'
sizes = [410,108,50,48,32]
explode = (0, 0.1, 0,0,0) # only "explode" the 2nd slice (i.e. 'Hogs')
fig1, ax1 = plt.subplots()
ax1.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%',
shadow=True, startangle=90)
ax1.axis('equal') # Equal aspect ratio ensures that pie is drawn as a circle.
plt.show()
普通眼科疾病是人群中一种常见病和多发病,在各种疾病中占有较大的比例,不同年龄人群的患者人数和所患疾病有所不同。总体来说,大部分疾病是对所有人群都多发的,说明预防眼科疾病与我们每个人都息息相关,但部分眼科疾病使中老年人群和儿童生病的概率更大,分别占到16.8%和8%。
眼睛有着重要的生理作用, 且十分脆弱, 易受到伤害, 老年人常由于青光眼、白内障、玻璃视网膜病变、眼外伤等住院治疗, 眼科住院患者多数需行手术治疗, 住院期间无法视物, 可能承受失明威胁, 极易引发心理负面情绪。加之逐步步入老龄化社会,孤寡老年住院患者更为严重,长期孤独生活,缺乏家人及社会关爱,无人陪伴,且在中国传统思想下,孤寡老人落寞感更为强烈,多数孤寡老人在住院前既已伴有明显的心里负面情绪,由于眼科疾病影响,无法视物打击可能导致患者精神失常,部分版友自杀倾向。严重的负面情绪可致使患者的应激反应,因而需要尤其重视老年患者。
研究表明, 眼科疾病主要包括眼眶骨折、神经纤维瘤、视网膜母细胞瘤、横纹肌肉瘤等, 可损害患儿眼球, 使其视力下降、眼球突出、黑影甚至失明, 影响患儿生活质量及身心健康。近年来, 随着人们生活习惯、生活结构改变等多因素共同作用, 眼科疾病患儿数量呈逐年上升趋势。有研究显示, 眼科疾病患儿在进行临床正确治疗时, 给予积极有效的护理配合可显著提高其预后效果。采用常规护理与个性化护理相结合可以减轻患儿的并发症发生率,并对负面心理情绪改善情况更为理想。
说明我们更应从多方位关注、支持儿童和老年人的眼科疾病防护及治疗。
import matplotlib.pyplot as plt
# 数据
labels = '有传染性','无传染性'
population = [51,609]
explode = [0,0] #用于突出显示0.1
colors=['Indianred','skyblue'] # 自定义颜色
# 中文乱码和坐标轴负号的处理
plt.rcParams['font.sans-serif'] = ['fangsong']
plt.rcParams['axes.unicode_minus'] = False
# 将横、纵坐标轴标准化处理,保证饼图是一个正圆,否则为椭圆
plt.axes(aspect='equal')
# 控制x轴和y轴的范围
plt.xlim(0,3.8)
plt.ylim(0,3.8)
# 绘制饼图
plt.pie(x = population, # 绘图数据
explode=explode, # 突出显示0.1
labels=labels, # 添加教育水平标签
colors=colors, # 设置饼图的自定义填充色
autopct='%.1f%%', # 设置百分比的格式,这里保留一位小数
pctdistance=0.3, # 设置百分比标签与圆心的距离
labeldistance = 0.5, # 设置教育水平标签与圆心的距离
startangle = 180, # 设置饼图的初始角度
radius = 1.3, # 设置饼图的半径
counterclock = True, # 是否逆时针,这里设置为顺时针方向
wedgeprops = {'linewidth': 0, 'edgecolor':'green'},# 设置饼图内外边界的属性值
textprops = {'fontsize':12, 'color':'k'}, # 设置文本标签的属性值
center = (0,0), # 设置饼图的原点
frame = 0 )# 是否显示饼图的图框,这里设置显示
# 删除x轴和y轴的刻度
plt.xticks(())
plt.yticks(())
# 添加图标题
plt.title('眼科疾病传染性概率')
# 显示图形
plt.show()
随着眼科门诊患者数量的逐年增加,因眼科设备等因素引起的感染风险正在加大,尤其是近年来国内医院发生急性结膜炎院内局部流行不良事件屡有报道。如何切实抓好眼科感染的控制,避免急性结膜炎等传染性疾病的感染,是门诊眼科一项重要工作。
总体来看,眼科疾病有传染性的概率较低,说明我们对大部分眼科疾病患者不应有可以回避远离的举动。在力所能及的范围内都尽微薄之力的帮助他们。
但眼科门诊具有病原体种类多、污染环节多、控制难度大以及易感人群集中等特点,是医院感染控制重点部门。诊室环境的严格消毒是避免空气污染的主要途径,采取“一医一患”,“一患一洗手”以及“一用一灭菌”等措施,是有效避免各类感染发生的有效手段。通过强化培训,增强医护人员的防范意识的自觉性,保证有传染性的眼科疾病得到很好的控制。
#导入包
import pandas as pd #数据处理包
import numpy as np #数据处理包
from wordcloud import WordCloud #绘制词云
import jieba #中文分词包
import jieba.posseg as pseg
import re #正则表达式,可用于匹配中文文本
import collections #计算词频
import matplotlib.pyplot as plt
#读取数据,使用pandas读取csv
df_question = pd.read_csv(r'C:\Users\zz\Desktop\眼科\眼科pycharm\PyCharm\scrapyspider\result.csv',low_memory=False,encoding='gbk')
#选择问题描述部分
df_mingcheng = df_question["mingcheng"].drop_duplicates().reset_index() #去除重复问题
list_mingcheng = df_mingcheng["mingcheng"].tolist()
mingcheng_all = "start"
for i in range(200): #选定一定范围作为示范,全部处理实在太多了
mingcheng_all = mingcheng_all+list_mingcheng[i]
# 文本分词
seg_list_exact = jieba.cut(mingcheng_all, cut_all = False) # 精确模式分词
object_list = []
remove_words = [u"'",u'[',u']',u',',u'于',u'的', u',',u'和', u'是', u'随着', u'对于', u'对',u'等',u'能',u'都',u'。',u' ',u'、',u'中',u'在',u'了',
u'性',u'如果',u'炎',u'眼'] # 自定义去除词库
for word in seg_list_exact: # 循环读出每个分词
if word not in remove_words: # 如果不在去除词库中
object_list.append(word) # 分词追加到列表
#选取中文:使用正则表达式
filter_pattern = re.compile('[^\u4E00-\u9FD5]+')
chinese_only = filter_pattern.sub('', mingcheng_all)
#中文分词
words_list = pseg.cut(chinese_only)
#计算词频,一行解决
word_counts = collections.Counter(object_list) # 对分词做词频统计
word_counts_top30 = word_counts.most_common(10) # 获取前30最高频的词
print (word_counts_top30)
#绘制词云
wc = WordCloud(background_color = "black",max_words = 300,font_path='C:/Windows/Fonts/simhei.ttf',min_font_size = 15,max_font_size = 50,width = 600,height = 600)
wc.generate_from_frequencies(word_counts)
plt.imshow(wc) # 显示词云
plt.axis('off') # 关闭坐标轴
plt.show() # 显示图像
[('视网膜', 21), ('眼眶', 19), ('青光眼', 18), ('巩膜', 13), ('病变', 13), ('综合征', 12), ('葡萄膜', 11), ('脉络膜', 10), ('角膜', 8), ('晶状体', 7)]
统计眼科疾病的名称词频,可知大部分眼科疾病都与视网膜有关,其次是青光眼、葡萄膜、脉络膜等。
视网膜有许多遗传的或者后天获得的疾病。例如:视网膜色素变性是一个遗传疾病,导致边缘视觉的失落;黄斑病变是指一系列由于黄斑中的细胞的死亡或者受伤而导致的中央视觉的丧失;视网膜脱落,视网膜从眼球上脱落下来;高血压和糖尿病会导致为视网膜提供营养的小血管的破坏,导致高血压性视网膜病变和糖尿病视网膜病变;视网膜母细胞瘤;黄斑水肿;视网膜黄斑衰退症等等。
而诱发视网膜疾病的原因主要有:甜食过量,吸烟等。
其中过量食用甜食不仅容易诱发或加重一些眼睛疾病,如近视眼、白内障、视神经炎等。这是因为甜食中的糖分在人体内代谢时需要大量的维生素B1,如果肌体中糖分摄入过多,维生素B1就会相对不足,而维生素B1是眼睛不可缺少的营养物质之一。 且糖尿病人并青光眼病人摄入糖类引起眼压变化导致网脱亦不罕见。所以,为了眼睛的健康,老人应尽量少吃甜食。
吸烟则是导致老年性黄斑变性,从而造成老年人低视力和眼盲的一个重要原因。
青光眼是指由于病理性眼压升高或持续升高导致视神经等组织受到损害, 从而损伤视功能, 造成患者视力下降、视野缩小甚至失明的一种眼科疾病, 青光眼是全世界不可逆致盲性眼科疾病的第二位。因为青光眼会造成不可逆的视神经损害, 尽早发现和诊断有利于及时治疗青光眼, 最大程度地减少视功能伤害, 降低失明率, 但我国依然有50%以上的青光眼患者未能及时被发现并接受治疗。
说明我们应开展对青光眼的宣传和教育可以提高人群的青光眼认知度, 促使人群积极参与青光眼防治, 帮助可能患有青光眼的患者进行检查和治疗。
葡萄膜对眼睛有着及其重要的作用,其相关疾病不可忽视,应该及早就医,以免对眼睛带来不可挽回的伤害。由此可以看出葡萄膜对于眼睛来说是很重要的,可以供给眼球营养;产生房水,调节眼内压;遮挡光线作用;排泄废物和有毒物质等等。一定要保护好葡萄膜一旦葡萄膜任何部分受损就很容易引起炎症,葡萄膜炎可累及葡萄膜的一部分或全部。各种原因引起的葡萄膜炎都可迅速损害眼睛,并可引起长期性并发症,如青光眼、白内障以及视网膜脱离等。
希望对眼科疾病的概括可以使人们重视眼科疾病,同时关注眼科患者的心理健康。