空字段赋值:NVL 给值为null的数据赋值 select nvl(age,20) from t_preson; 时间类: date_format:格式化时间 select date_format(time,''yyyy-MM-dd") ; date_add:时间和天数相加 select date_ Read More
posted @ 2020-06-15 21:01 saber丶吾王 Views(148) Comments(0) Diggs(0) Edit
select * from a where id in (select id from b) 等价于: for select id from b for select 8 from a where a.id = b.id 当b表数据必须小于a表数据时,in优于exists select * from Read More
posted @ 2020-06-11 20:55 saber丶吾王 Views(179) Comments(0) Diggs(0) Edit
索引失效: 全值匹配:索引全部引用 最佳左前缀法则,查询从索引的最左前列开始并且不跳过中间索引 索引列上少计算或类型转换 范围之后全失效 尽量使用覆盖索引,查询字段和 ,避免使用 select * 使用 !=或<>会导致无法使用索引,进行全表查询 is null 或 is not null 无法使用 Read More
posted @ 2020-06-11 15:55 saber丶吾王 Views(100) Comments(0) Diggs(0) Edit
合并 merge,concat,join pd.merge(df1,df2,on=‘列名’,how='') df1.join(df2,how='outer',on='') pd.concat([df1,df2],join='outer') 去重 drop_duplicates df1.drop_du Read More
posted @ 2019-06-18 18:29 saber丶吾王 Views(197) Comments(0) Diggs(0) Edit
多表查询: 显示内连接: select 字段列表 from 表名1 inner join 表名1 on 条件 * inner 可忽略 select * from student inner join class on student.clas_id=class.id 隐式内连接: 使用where: Read More
posted @ 2019-04-10 00:18 saber丶吾王 Views(156) Comments(0) Diggs(0) Edit
合并数据集: 创建一个能创建dataframe的函数 def make_data(cols,ind): data={c:[strc(c)+str(i) for i in ind] for c in cols} return pd.DataFrame(data,ind) make_data('ABC' Read More
posted @ 2019-04-02 17:22 saber丶吾王 Views(196) Comments(0) Diggs(0) Edit
层级索引: index=[('a',2010),('b',2011),('c',2010'),('a',2012),('e',2010),('f',2011)] age=[18,17,18,16,18,17] 常规创建 pop =pd.Series(age,index=index) MultiInd Read More
posted @ 2019-04-02 15:32 saber丶吾王 Views(198) Comments(0) Diggs(0) Edit
import numpy as py import pandas as pd Series对象 data= pd.Series([0.25,0.5,0.75,1.0]) 默认索引是数字 data=pd.Series([0.25,0.5,0.75,1.0],index=['a','b','c','d' Read More
posted @ 2019-04-02 12:04 saber丶吾王 Views(271) Comments(0) Diggs(0) Edit
排序: x=np.array([2,5,6,2,3,5]) np.sort(x) 不改变原数组 x.sort() 改变原数组 i=np.argsort(x) 返回排序好的索引值 x[i] 使用花哨索引返回排序好的数组 x=np.random.randint(0,10,(4,6)) np.sort(x Read More
posted @ 2019-04-01 17:07 saber丶吾王 Views(96) Comments(0) Diggs(0) Edit
逻辑符 : == != < > <= >= x=np.array([1,3,5]) x<3 array([True,False,,False]) (2*x) == (x*2) array([False,False,,False]) 统计个数: np.count_nonzero(x>6) np.sum Read More
posted @ 2019-04-01 16:35 saber丶吾王 Views(134) Comments(0) Diggs(0) Edit