这个单子因为时间以及在家的缘故,做一半就没时间了,还有就是遇到一个问题,当正则表达式修改之后格式有点看不懂,需要重新append到列表进行循环遍历输出,这样才更好进行再修改

import pandas as pd
import numpy as np
import re
import matplotlib.pyplot as plt
%matplotlib inline
raw=pd.read_excel('汇总.xlsx')
raw.head()
txt
0 PT P
1 PN JP2019213676-A
2 TI Odor modulation agent useful for modulating...
3 AU BAO X X
4 TSUJIMOTO H
# 章节判断
chapnum = 0
for i in range(len(raw)):if raw['txt'][i] == "PT P":chapnum += 1raw.loc[i, 'chap'] = chapnum
rawgrp = raw.groupby('chap')
chapter = rawgrp.agg(sum) # 只有字符串列的情况下,sum函数自动转为合并字符串
chapter.head()
txt
chap
1.0 PT PPN JP2019213676-ATI Odor modulation agent ...
2.0 PT PPN WO2019237159-A1TI Treating solid waste ...
3.0 PT PPN US2019382319-A1; EP3581551-A1TI Bacteri...
4.0 PT PPN WO2019237134-A1TI Aerobic waste compost...
5.0 PT PPN CN110550724-ATI Biological filler usefu...
def pn(x):patten=re.compile('PN (.*?)TI',re.S)a=re.findall(patten,x)return a
chapter['pn']=chapter.apply(lambda x: pn(x['txt']), axis=1)
def UT(x):patten=re.compile('UT (.*?)ER',re.S)return re.findall(patten,x)
chapter['UT']=chapter.apply(lambda x: UT(x['txt']), axis=1)
def TI(x):patten=re.compile('TI (.*?)AU',re.S)return re.findall(patten,x)
chapter['TI']=chapter.apply(lambda x: TI(x['txt']), axis=1)
# chapter['TI']=chapter['txt'].str.extract("(TI (.*?)AU)")
chapter.head()
txt pn UT TI
chap
1.0 PT PPN JP2019213676-ATI Odor modulation agent ... [JP2019213676-A] [DIIDW:2019A6103W] [Odor modulation agent useful for modulating s...
2.0 PT PPN WO2019237159-A1TI Treating solid waste ... [WO2019237159-A1] [DIIDW:2019A6029L] [Treating solid waste extracted from liquid wa...
3.0 PT PPN US2019382319-A1; EP3581551-A1TI Bacteri... [US2019382319-A1; EP3581551-A1] [DIIDW:2019A6044K] [Bacterially decomposing organic waste materia...
4.0 PT PPN WO2019237134-A1TI Aerobic waste compost... [WO2019237134-A1] [DIIDW:2019A4913N] [Aerobic waste composting chamber used for sol...
5.0 PT PPN CN110550724-ATI Biological filler usefu... [CN110550724-A] [DIIDW:2019A5191S] [Biological filler useful for treating livesto...
# chapter['pn']=chapter['pn'].str.extract('([^\[\]]+)')
chapter['pn']=chapter['pn'].str.replace('[','')
# chapter['pn']=chapter['pn'].str.replace(']','')
chapter.head()
txt pn UT TI
chap
1.0 PT PPN JP2019213676-ATI Odor modulation agent ... NaN [DIIDW:2019A6103W] [Odor modulation agent useful for modulating s...
2.0 PT PPN WO2019237159-A1TI Treating solid waste ... NaN [DIIDW:2019A6029L] [Treating solid waste extracted from liquid wa...
3.0 PT PPN US2019382319-A1; EP3581551-A1TI Bacteri... NaN [DIIDW:2019A6044K] [Bacterially decomposing organic waste materia...
4.0 PT PPN WO2019237134-A1TI Aerobic waste compost... NaN [DIIDW:2019A4913N] [Aerobic waste composting chamber used for sol...
5.0 PT PPN CN110550724-ATI Biological filler usefu... NaN [DIIDW:2019A5191S] [Biological filler useful for treating livesto...
def UT(x):patten=re.compile('\d\d\d\d',re.S)a=re.findall(patten,str(x))return str(a).split(",")[0]
chapter['UT']=chapter.apply(lambda x: UT(x['UT']), axis=1)
chapter['UT']=chapter.apply(lambda x: UT(x['UT']), axis=1)
# chapter['UT']=chapter['UT']
# def UT(x):
#     return str(x).split(";")[0]
# chapter['pn']=chapter.apply(lambda x: UT(x['pn']), axis=1)
chapter=chapter.drop(['txt'],axis=1)
chapter.head()
pn UT TI
chap
1.0 NaN ['2019'] [Odor modulation agent useful for modulating s...
2.0 NaN ['2019'] [Treating solid waste extracted from liquid wa...
3.0 NaN ['2019'] [Bacterially decomposing organic waste materia...
4.0 NaN ['2019'] [Aerobic waste composting chamber used for sol...
5.0 NaN ['2019'] [Biological filler useful for treating livesto...
chapter['pn']=chapter['pn'].str.extract('([^\[\]\']+)')
chapter['UT']=chapter['UT'].str.extract('([^\[\]\']+)')
chapter.head()
pn UT TI
chap
1.0 NaN 2019 [Odor modulation agent useful for modulating s...
2.0 NaN 2019 [Treating solid waste extracted from liquid wa...
3.0 NaN 2019 [Bacterially decomposing organic waste materia...
4.0 NaN 2019 [Aerobic waste composting chamber used for sol...
5.0 NaN 2019 [Biological filler useful for treating livesto...

爬出从1963年到2019年,每年专利的数量,列excel表

chapter.dropna(inplace=True)
chapter['UT']=chapter['UT'].drop(chapter[chapter['UT']=='5575'].index)
request1=chapter.groupby(by='UT')['pn'].count()
request1.head()
UT
1981    1
1984    1
1990    3
1991    1
1992    2
Name: pn, dtype: int64
from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
#设置画布
asd,sdf = plt.subplots(1,1,dpi=100)
#获取排前10条类型
request1.plot(kind='bar',title='数量分布',ax=sdf)
# plt.legend(['数量'])
plt.show()

各个国家和前十的机构,都申请了多少专利

chapter['organization']=chapter['pn'].str[:2]
chapter['organization'].value_counts()
CN    275
KR     22
WO     15
ID     11
JP     11
EP      7
IN      6
DE      5
FR      4
US      4
RU      4
BR      3
NL      2
GB      1
PL      1
PH      1
TW      1
Name: organization, dtype: int64
# import pandas as pd
# f = pd.ExcelFile('汇总.xlsx')
# f.sheet_names  # 获取工作表名称
# data = pd.DataFrame()
# for i in f.sheet_names:
#     d = pd.read_excel('汇总.xlsx', sheetname=i)
#     data = pd.concat([data, d])

20200216_re数据处理相关推荐

  1. 数据结构(03)— 数据处理基本操作(数据的查找、新增、删除、修改)

    我们先来看一个关于查找的例子.查找,就是从复杂的数据结构中,找到满足某个条件的元素.通常可从以下两个方面来对数据进行查找操作:​ 根据元素的位置或索引来查找: 根据元素的数值特征来查找. 针对上述两种 ...

  2. 大规模数据处理Apache Spark开发

    大规模数据处理Apache Spark开发 Spark是用于大规模数据处理的统一分析引擎.它提供了Scala.Java.Python和R的高级api,以及一个支持用于数据分析的通用计算图的优化引擎.它 ...

  3. 2021年大数据Spark(二十六):SparkSQL数据处理分析

    目录 SparkSQL数据处理分析 基于DSL分析 基于SQL分析 第一步.注册为临时视图 第二步.编写SQL,执行分析 ​​​​​​​SparkSQL数据处理分析 在SparkSQL模块中,将结构化 ...

  4. 电子表单系列谈之表单数据处理

    袁永福( http://www.xdesigner.cn ) 2007-8-16 点击下载其表单工具概念版本 一般的电子表单工具都要求能自动显示和保存关系型数据库中的数据,比如可以使用SQL语句查询数 ...

  5. python怎么做彩票概率_用Python一次性把论文作图与数据处理全部搞定!

    一入科研深似海-- 年底将近,"防脱发用生姜还是黑芝麻?",研究僧们又开始为自己所剩无几的头发发愁了. 文献看到头秃,前沿课题总是无缘 置顶了一页实验组微信群.QQ群,想追踪前沿文 ...

  6. 【radar】毫米波雷达动态障碍物检测相关论文汇总(聚类、分类、稀疏2D点、4D点、雷达成像、原始数据处理)(4)

    [radar]毫米波雷达动态障碍物检测相关论文汇总(聚类.分类.稀疏2D点.4D点.雷达成像.原始数据处理)(4) Detection of Dynamic Objects Clustering 20 ...

  7. Javascript中二进制数据处理方法

    Javascript中二进制数据处理方法 转载于:https://www.cnblogs.com/motadou/archive/2012/02/19/2358514.html

  8. nodejs操作sqlserver数据_pyspark操作MySQL、SQLServer数据库进行数据处理操作

    欢迎访问本人的CSDN博客[Together_CZ],我是沂水寒城. https://yishuihancheng.blog.csdn.net 在大数据处理领域里面,Hadoop和spark可以说是最 ...

  9. python中符号计算输出数学_Python科学计算与数据处理—符号运算库.doc

    Python 科学计算与数据处理 - 符号运算库 符号运算库目录从示例开始欧拉恒等式球体体积数学表达 式符号数值运算符和函数符号运算表达式转换和简化方程目录微分 方程积分其他函数符号运算库. 它的目标 ...

  10. jpanel不使用jframe保存的图片为空_使用DataBinding还在为数据处理头疼?这篇文章帮你解决问题

    前言 在前几年兴起了MVVM架构设计模式,最具有代表的框架就是DataBinding,虽然这种设计架构非常新颖,但是在使用中仍然还有很多痛点,所以我当时觉得短时间这个设计架构可能不会太流行. 最近接手 ...

最新文章

  1. ros知识:关于catkin_init_workspace不能执行的错误
  2. Kubernetes共享使用Ceph存储
  3. CSS 选择器权重计算规则
  4. VS2010中 C++创建DLL图解
  5. Http 四种请求访问代码 HttpGet HttpPost HttpPut HttpDelete .
  6. Ubuntu18.04 安装 nvidia2080Ti显卡驱动
  7. 常用圆圈数字序号(1~50)
  8. 微信小程序人脸识别功能(wx.faceDetect)、带扫脸动画、人脸图片获取(upng.js)及位置展示
  9. 让手机成为电脑的摄像头,Droidcam(linux) 的安装及使用
  10. php传值和引用哪个效率高,php方法传值和传引用性能比较
  11. QCC3040---UI tones module
  12. h5实现图片预览效果,模拟淘宝上传图片样式
  13. 个人微信公众号申请步骤
  14. zabbix部署及监控测试
  15. word取消英文首字母自动大写问题
  16. Vue实现在线编辑excel
  17. BootStrap之标签页切换
  18. Android studio 放大字体
  19. 全景拼接python旗舰版
  20. Flutter 嵌套深、刷新乱?少年,你怕是连Flutter的门槛都没摸到!

热门文章

  1. 推荐最近使用的一个APP
  2. 编写可维护的javascript代码--- 2015.11.21(基本格式化)
  3. oracle行号排序问题
  4. java day07【Scanner类、Random类、ArrayList 类】
  5. 开启es6——搭建开发环境
  6. 常用的python内置方法
  7. 2016年上半年数据库系统工程师上午真题
  8. 机器学习、数据分析类面经分享
  9. cobbler实现自动安装
  10. an existing tansporter instance is currently uploading this package 解决方法