遥指杏花村

博客园 首页 新随笔 联系 订阅 管理

2020年3月15日 #

摘要: 阅读全文
posted @ 2020-03-15 10:19 遥指杏花村 阅读(94) 评论(0) 推荐(0) 编辑

2020年3月14日 #

摘要: 方法(一)通过字典追加(列名要一致) data={'a':50,'b':60,'c':70} df=df.append(data,ignore_index=True) 方法(二)通过Serise 1 data=pd.Serise([50,60,70],index=list('abc')) 2 df= 阅读全文
posted @ 2020-03-14 22:58 遥指杏花村 阅读(4241) 评论(0) 推荐(0) 编辑

摘要: 方法(一)直接赋值 df['D']=80 方法(二)assign追加多列 df = df.assign( AB=df.A+df.B, BC=df.B+df.C ) #追加AB列和BC列 方法(三)条件追加 df['评级']=''df.loc[df['语文']>80,'评级']='优秀' #大于80分 阅读全文
posted @ 2020-03-14 16:31 遥指杏花村 阅读(428) 评论(0) 推荐(0) 编辑

摘要: df['温度']=df['温度'].str.replace('℃','').astype('int32') 阅读全文
posted @ 2020-03-14 15:24 遥指杏花村 阅读(480) 评论(0) 推荐(0) 编辑

2020年3月13日 #

摘要: 方法(一) plt.subplot(总行数,总列数,序号) x=np.arange(0,7,0.1) y1=np.sin(x) y2=np.cos(x) y3=2*x+6 y4=-2*x+9 plt.subplot(2,2,1) plt.plot(x,y1) plt.subplot(2,2,4) p 阅读全文
posted @ 2020-03-13 21:01 遥指杏花村 阅读(383) 评论(0) 推荐(0) 编辑

摘要: 一组彩票数据 (一)统计第a1列 0~9各个数字出现的次数 pd.value_counts(df.a1)或者写成df.a1.value_counts( (二)统计所有的数据中0~9各个数据出现的次数 pd.value_counts(df.values.flatten()) 阅读全文
posted @ 2020-03-13 20:40 遥指杏花村 阅读(229) 评论(0) 推荐(0) 编辑

摘要: 有两种方法 (一) plt.rcParams['font.sans-serif']='SimHei'] (二) from matplotlib import font_manager #导入相应模块 font1 = font_manager.FontProperties(fname="C:/Wind 阅读全文
posted @ 2020-03-13 20:25 遥指杏花村 阅读(118) 评论(0) 推荐(0) 编辑

摘要: 数据 查询 a1=a2 并且 a1=a3 的所有数据 格式:df[ ( ) & ( ) ] df[(df['a1']==df['a2'])&(df['a1']==df['a3'])] 阅读全文
posted @ 2020-03-13 20:16 遥指杏花村 阅读(275) 评论(0) 推荐(0) 编辑

摘要: 原理:把符合条件的数据赋值给中间变量,把中间变量的index作为删除条件 原数据 删除所有 和<100 的数据 tmp=df[df['和']<100] df.drop(tmp.index)# 也可写在一起 df.drop(df[df['和']<100].index) df.drop(5) 删除第五行 阅读全文
posted @ 2020-03-13 11:38 遥指杏花村 阅读(8070) 评论(0) 推荐(0) 编辑

2020年3月3日 #

摘要: 用requests.get()方法获取网页代码 用beautifulsoup模块解析出图片地址 再用requests模块以图片地址为参数,再发一次请求。 with open as f 以二进制保存图片信息。img.content import requests from bs4 import Bea 阅读全文
posted @ 2020-03-03 14:34 遥指杏花村 阅读(576) 评论(0) 推荐(0) 编辑