![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Chen不知
这个作者很懒,什么都没留下…
展开
-
round()保留有效位数,在SAS SQL Python,以及SAS中运行SQL语句的注意事项; 以及ceil,floor的使用
Round()保留有效位数,在SAS SQL Python,以及SAS中运行SQL语句的注意事项; 以及ceil,floor的使用首先提醒下,SAS中的round(),和SQL,Python中,还是有区别的,今天在分析时编程,发现筛选的结果出现问题,后来才发现其中用法的不同。在SQL和Python中,round(x,n),表示的是x保留n位小数,这个比较常见,例如:x=3.1415926round(x,2)#结果:3.14而在SAS中:data prac;x=3.1415926;y=rou原创 2020-09-08 10:29:40 · 3620 阅读 · 1 评论 -
删除空格的方法:SQL: trim replace; SAS: left right trim strip compress compbl; python: x.strip() x.replace()
删除空格的方法:SQL: rtrim ltrim trim replace; SAS: left right trim strip compress compbl; python: x.strip x.rstrip x.lstrip x.replace今天分享下,文本处理时,删除空格的方法,由于最近再SAS, Python和SQL中都进行了类似的处理,发现三种语言间,去空格的方法非常容易混淆,所以就对三者列出来,进行区分。尤其是trim在SQL和SAS中,十分容易混淆。SQL中:select "x"原创 2020-08-18 08:46:09 · 923 阅读 · 0 评论 -
python matplotlib 作图时 中文标题 图例 无法显示/出现乱码
python matplotlib 作图时 中文标题 图例 无法显示/出现乱码画图时出现上述问题,只要一下代码就可以解决import matplotlib.pyplot as pltplt.rcParams['font.sans-serif']=['Microsoft YaHei']原创 2020-08-03 16:04:53 · 2612 阅读 · 1 评论 -
Python pandas实现sql的where筛选功能以及.isin的应用
Python pandas实现sql的where筛选功能以及.isin的应用首先创建一个dataframeimport pandas as pddata=pd.DataFrame(dict(zip(['Col1','Col2','Col3'],[[1,2,3,4],['a','b','c','d'],[1,2,3,4]])))例如: 要筛选变量Col1中大于2的数据SQL:select * from data where Col1>2;Python:data[data['Col1'原创 2020-07-28 16:06:59 · 1645 阅读 · 0 评论 -
Python中size shape len的区别及用法
Python中size shape len的区别及用法创建dataframesize shape len的区别及用法np.size()的用法创建dataframe首先创建一个dataframeimport pandas as pddata=pd.DataFrame(dict(zip(['Col1','Col2','Col3'],[[1,2,3,4],['a','b','c','d'],[1,2,3,4]])))这里介绍下,利用zip和dict来创建字典zip(['Col1','Col2','原创 2020-07-28 13:16:25 · 3176 阅读 · 0 评论 -
Python pandas导入/读取数据
Python_pandas导入/读取数据导入csv导入excel作为进行分析的第一步,我们首先需要读取数据,今天就来分享下利用pandas读取excel和csv数据导入csvimport pandas as pddata=pd.read_csv('C:/Users/CS/Desktop/data.csv')csv的读取非常简单,只要注意路径中使用 / 或者 \\, 而不要使用 \利用 pd.read_csv()导入exceldata=pd.read_excel('C:\\Users\\CS\原创 2020-07-27 20:59:54 · 657 阅读 · 0 评论