
python使用和学习
贺俊宏
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Pathlib的基本用法
在项目运行的时候经常设计文件路径的读取与处理,Pathlib提供了非常方便的接口处理文件路径,本文将介绍一些Pathlib的基本用法。原创 2023-05-12 18:22:08 · 709 阅读 · 1 评论 -
利用python从蛋白文件中提取特定类型的原子
从蛋白文件中提取某种原子并写出原创 2022-11-16 10:49:05 · 701 阅读 · 0 评论 -
python处理含重复值的实验数据
项目场景:师妹有这样一张表:希望能按inchikey进行分组,然后删除掉logD最大值最小值数据相差超过百分之三十的数据,对剩下的数据进行取平均数的方法进行去重解决方案:import pandas as pddata = pd.read_csv("xxxxxxxxx")#删除浮动超过百分之30的数据data_valid = data.groupby( ["Smiles (InChiKey)"], as_index=False).filter( lambda x:max(x.log原创 2022-03-05 16:11:24 · 1129 阅读 · 0 评论 -
如何连接成组箱线图中的平均值(seaborn)
项目场景:师妹想要如下图的效果问题描述:理所应到得想到用箱线图组合折线图就可以,但出来的图发现不对劲:点并不在箱线图之上,而是按照坐标点成一条竖线解决方案:为pointplot函数加入dodge参数,下面看看seaborn官网对这个参数的解释:dodge:bool or float, optionalAmount to separate the points for each level of the hue variable along the categorical axis.(原创 2022-03-03 11:26:20 · 3367 阅读 · 3 评论 -
基于rdkit将smiles转换为smarts
基于rdkit将smiles转换为smarts载入包转换结果载入包from rdkit import Chem载入smilesmol = Chem.MolFromSmiles("CC1=C(N(N=N1)C)C2=CC3=C(C4=C(N3C(C5CCOCC5)C6=CC=CC=C6)C=C(C=C4)C(C)(C)O)N=C2")转换s = Chem.MolToSmarts(mol)smart = s.replace('#6', 'C').replace('#8', 'O').repla原创 2021-03-25 17:10:47 · 2907 阅读 · 2 评论 -
每日营养摄入计算与主要的食物成分表(健身必备)
闲话少说,上代码需要先安装一个包 skiimagepip install scikit-image或者用conda装 conda install scikit-image@author: recherHE@Email:[email protected]"""from skimage import iodef Conversion(work_day): if work_day <1: frequency = 1.2 elif work_d原创 2020-05-08 23:19:27 · 2418 阅读 · 0 评论 -
[网络爬虫] css selector (beautiful soup)
https://piaosanlang.gitbooks.io/spiders/content/02day/section2.4.html原创 2019-11-04 09:18:34 · 367 阅读 · 0 评论 -
合并key值相同的字典
d1 = {'a':1,'b':2,'c':3}d2 = {'a':4,'b':5,'c':6}d3 = {'a':[1,4],'b':[2,5],'c':[3,6]}如上 想用d1,d2合成为d3格式.首先想到的是利用dict的update函数,但发现存在如下问题:d1 = {'a':1,'b':2,'c':3}d2 = {'a':4,'b':5,'c':6}d3 ={}d3...原创 2019-10-31 19:39:56 · 4888 阅读 · 0 评论 -
利用python进行绘图的学习过程(持续更新)
matplotlib.pyplot使用matplotlib进行绘图 其所产生的图片有如下图所示的部件对于pyplot模块中的功能,始终有一个“当前”图形和轴(根据要求自动创建)。例如,在下面的例子中,在第一次调用plt.plot创建轴,则后续调用plt.plot在同一坐标添加额外的线,以及 plt.xlabel,plt.ylabel,plt.title和plt.legend设置轴标签和标题...原创 2019-10-26 13:31:36 · 551 阅读 · 0 评论 -
enumerate的用法
一般我们用对一个可迭代对象进行索引,需要加上数字如案例1,我们就需要seq[1]才能得到列表中的two这个项.而在使用了enumerate之后,可以直接输出两项,分别是 index和这个index所对应的项.更方便我们进行后续操作,...原创 2019-10-03 14:36:52 · 412 阅读 · 0 评论 -
爬虫时候的进度条使用
# 最基本的用法import timefrom tqdm import tqdmfor i in tqdm(range(9)): time.sleep(0.1)# 效果如下>>> 100%|██████████| 10/10 [00:01<00:00, 9.79it/s]# trange类似于tqdmimport timefrom tqdm impor...原创 2019-09-29 10:54:27 · 664 阅读 · 1 评论 -
split和rsplit的使用
今天学到了 rsplit再也不用傻傻傻的数最后一个是第几个了str_temp = "aaa.bbb.cc.dd"ret1,ret2 = str_temp.rsplit(".",maxsplit=1)ret3,ret4 = str_temp.split(".",maxsplit=1)ret5,ret6,ret7 = str_temp.split(".",maxsplit=2)print...原创 2019-09-14 17:39:59 · 1235 阅读 · 0 评论 -
python的基本资源库说明链接
这里是引用|requests库| http://cn.python-requests.org/zh_CN/latest/index.html ||beautifulsoup–|--https://beautifulsoup.readthedocs.io/zh_CN/latest/|| | |原创 2019-08-16 10:29:12 · 271 阅读 · 0 评论 -
python中range()函数的用法
python中range()函数的用法**Python中range()函数的用法1、函数原型:range(start, end, scan):参数含义:start:计数从start开始。默认是从0开始。例如range(5)等价于range(0, 5);end:技术到end结束,但不包括end.例如:range(0, 5) 是[0, 1, 2, 3, 4]没有5scan:每次跳跃的间距,...转载 2019-08-16 09:57:57 · 6339 阅读 · 0 评论