![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python学习记录
文章平均质量分 80
偷偷搞塌
这个作者很懒,什么都没留下…
展开
-
from matlab 2 python 记录win10中通过anaconda安装和使用smop
anaconda promt中输入pip install smop最后会显示smop安装成功。找到自己电脑中smop.exe所在位置比如我的电脑中是C:\Users\dell\Anaconda3\Scripts\smop.exe,双击运行smop.exe,一闪而过之后,接下一步打开anaconda promt将目录cd到BDT.m文件所在的文件夹,并且按照下图中输入smop ValueSw...原创 2019-12-03 09:35:13 · 1778 阅读 · 5 评论 -
python中datetime、calendar等包关于自然月划分的一些自写程序
参考网址:《python 获取当前月份月初日期和月末日期》2016年11月18日 14:24:13 作者:junli_chenhttps://blog.csdn.net/junli_chen/article/details/53215956《Python获取两时段内日期、月份、小时的列表清单》2018年06月28日 17:34:22 作者:BabyFish13https://b...原创 2019-06-21 16:08:55 · 795 阅读 · 0 评论 -
20190430正则表达式知识小结-对比SQL中like语句的pattern匹配
在cmd以及jupyter中都可以通过help(sum)import rehelp(re.findall)#手段来获取对于模块的帮助文档关于python中正则表达式的知识总结. 可以匹配任意字符但是不包括换行符\n pyt.on—pytmon(不包括换行符的这一点可以通过类似函数findall(pattern, string,flags=0)中的flags参数解决,flags...原创 2019-04-30 09:28:16 · 695 阅读 · 0 评论 -
20190419代码学习备份
# -*- coding: utf-8 -*-"""Created on Fri Apr 19 09:39:54 2019@author: pt0531"""import numpy as npimport pandas as pdimport rep1=open(r"C:\Users\pt0531\Desktop\data1.csv",encoding='gbk',error...转载 2019-04-19 11:10:17 · 346 阅读 · 0 评论 -
python遍历列表易出错!!!!!
参考网址:https://segmentfault.com/a/1190000007214571#正确做法之一#或者遍历拷贝的List,操作原始的Listfor item in aj_yuliaoku[:]:if len(item) <= 4:aj_yuliaoku.remove(item)aj_yuliaokuLen=[]for i in aj_yuliaoku:aj_y...原创 2019-04-03 11:36:59 · 460 阅读 · 0 评论 -
Python-Levenstein包的安装+使用说明(感恩的心,感谢前辈们的分享)
参考知乎回答:https://zhuanlan.zhihu.com/p/37995301whl文件的安装方法参见网址:https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels要注意cmd中路径的切换不然安装会报错.没有报错,安装成功...原创 2019-03-28 10:41:15 · 734 阅读 · 0 评论 -
习题未做-2019年3月15日-面向对象编程(full_version_study_recording)
#(1)类和实例#面向对象编程——Object Oriented Programming,简称OOP,是一种程序设计思想#OOP把对象作为程序的基本单元,一个对象包含了&lt;数据&gt;和&lt;操作数据的函数&gt;。#OOP把计算机程序视为一组对象的集合#而每个对象都可以接收其他对象发过来的消息并处理这些消息#计算机程序的执行就是一系列消息在各个对象之间传递#自定义的对象数据类型...转载 2019-03-19 10:31:58 · 227 阅读 · 0 评论 -
未做习题--20190318--正则表达式
在正则表达式中,如果直接给出字符,就是精确匹配‘00\d’可以匹配’007’,但无法匹配’00A’;‘\d\d\d’可以匹配’010’;‘\w\w\d’可以匹配’py3’;小数点.可以匹配任意字符,所以:'py.‘可以匹配’pyc’、‘pyo’、'py!'等等。#以下是对匹配类型的描述:\d可以匹配一个数字\w可以匹配一个字母或数字小数点.可以匹配任意字符\s可以匹配一个空格(...转载 2019-03-19 09:36:24 · 122 阅读 · 0 评论 -
python3中 ->的意义
参考网址:https://stackoverflow.com/questions/14379753/what-does-mean-in-python-function-definitionspython3中 ->的意义According to this, the example you’ve supplied:def f(x) -> 123: return xwil...转载 2019-06-25 17:27:31 · 2939 阅读 · 0 评论 -
python程序运行计时
reference:https://blog.csdn.net/wangshuang1631/article/details/54286551python脚本使用统计时间的方式是time.clock(),而这种方式统计的是CPU的执行时间,不是程序的执行时间。区分 程序进行时间 与 CPU运行时间...转载 2019-06-26 10:04:42 · 3101 阅读 · 0 评论 -
python logging模块 写日志
可能是我目前看到适合菜鸟的最好的一篇介绍logging的文章:reference 1: https://blog.csdn.net/liurenfeng007/article/details/81216744author: 留晨说timestamp: 20190626阅读并学习reference 2:https://blog.csdn.net/u010895119/article/deta...转载 2019-07-30 15:23:19 · 281 阅读 · 0 评论 -
dataframe apply、map、expand的神奇用法
pdd=pd.DataFrame([[4,9],]*3, columns=['A','B'])pddOut[8]: A B0 4 91 4 92 4 9>>> df.apply(np.sum, axis=0)# 逐行相加,即求**列和**A 12B 27dtype: int64>>> df.apply(...翻译 2019-07-11 09:35:29 · 1662 阅读 · 0 评论 -
break\continue对于循环while\for的作用再次温习
# -*- coding: utf-8 -*-"""Created on Sun Jul 14 09:31:58 2019@author: pt0531"""def pairwise(arr, arg): import math result = 0 for i in range(len(arr)): for j in range(i+1,le...原创 2019-07-14 10:27:15 · 144 阅读 · 0 评论 -
python-with open函数的用法
open() 函数返回一个file object,通常需要传入两个参数 filename和mode—— open(filename, mode).f = open(‘workfile’, ‘w’)第一个参数filename是包含文件地址的str第二个参数mode用来指定文件被使用的方式,The mode argument is optional;如果不指定则默认为mode= ‘r’ 即只读模...翻译 2019-06-28 11:04:17 · 37493 阅读 · 4 评论 -
python--assert函数的作用,早发现错误早停止run function
reference1: https://blog.csdn.net/humanking7/article/details/45950781#示例,assert在输入变量不满足类型条件时,及时停止函数的continue running报错并退出函数def f(x:str)->int: assert type(x)==str,'输入x的格式不满足str类型' jieguo=l...转载 2019-06-27 13:55:53 · 1431 阅读 · 0 评论 -
python中dataframe间通过类似主键的功能进行链接、拼接
reference 1: http://blog.csdn.net/zutsoft/article/details/51498026author:lianghc《 连接:merge 通过键拼接列》#两个dataframe之间通过某一个变量的值作为主键们进行拼接import pandas as pd online_Df=pd.DataFrame({'Cate_cd':['A类','B...原创 2019-06-27 11:21:15 · 1519 阅读 · 0 评论 -
python df.groupby对象——支持迭代、count等操作
import pandas as pdpdd=pd.read_csv(r'C:\Users\pt0531\Desktop\2019-01.csv',dtype=str)print(pdd.columns)len(pdd) # 144538#4列['so_date', 'so_voucher_no', 'series_code']grouped=pdd.groupby(pdd['so_vo...原创 2019-06-27 16:17:24 · 4928 阅读 · 0 评论 -
python——在cmd模式下输入pip list查看已经安装的模块module
C:\Users\pt0531>pip list原创 2019-03-21 14:06:27 · 6312 阅读 · 0 评论 -
未整理--20190315——函数式编程Functional Programming-学习笔记——廖雪峰老师的教程
函数是Python内建支持的一种封装,我们通过把大段代码拆成函数,通过一层一层的函数调用,就可以把复杂任务分解成简单的任务——这种分解可以称之为面向过程的程序设计——函数就是面向过程的程序设计的基本单元。函数式编程Functional Programming——虽然也可以归结到面向过程的程序设计,但其思想更接近数学计算我们首先要搞明白计算机(Computer)和计算(Compute)的概念。...转载 2019-03-14 17:02:05 · 290 阅读 · 0 评论 -
20190314--python学习笔记—高级特性——廖雪峰老师python教程
python-高级特性#比如构造一个1, 3, 5, 7, ..., 99的列表,可以通过循环实现:L=[]n=1while n&amp;amp;amp;lt;=99: L.append(n) n=n+2print(L)#输出结果C:\Users\pt0531\Desktop&amp;amp;amp;gt;python JJJtest1.py[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, ...转载 2019-03-14 16:14:19 · 497 阅读 · 0 评论 -
Python——axis到底是啥——axis=0指的是逐行,axis=1指的是逐列
axis=0指的是逐行,axis=1指的是逐列df=pd.DataFrame([[1,1,1,1],[2,2,2,2],[3,3,3,3]])print(df)0 1 2 30 1 1 1 11 2 2 2 22 3 3 3 3df.mean(axis=1)# 按照意思axis取1意思是逐列计算平均值,那么其实算出来的是行平均mean of rowOu...原创 2019-02-28 14:24:45 · 6475 阅读 · 0 评论 -
Python---pandas的常用函数的索引见汇总blog
科普:pandas的常用函数的索引见汇总bloghttps://blog.csdn.net/Read__Book/article/details/73730800df.rename(columns=lambda x: x + 1):批量更改列名df.rename(columns={‘old_name’: ‘new_ name’}):选择性更改列名df.set_index(‘column_...原创 2019-02-28 13:43:45 · 834 阅读 · 0 评论 -
from sklearn.externals import joblib以及dump存储模型,joblib.load()调用原模型
书scikit-learn机器学习-page51示例代码:import matplotlib.pyplot as pltfrom sklearn import datasetsdigits=datasets.load_digits()from sklearn.model_selection import train_test_splitXtrain, Xtest, Ytrain, Yte...转载 2019-02-22 17:06:07 · 13831 阅读 · 1 评论 -
python 求解多项式以及 用多项式拟合数据
python 求解多项式——函数poly1d()注意是1不是L、l此处多项式为 x^2-4*x+3python多项式拟合数据import matplotlib.pyplot as pltimport numpy as npn_dots=20n_order=3# 确定好多项式的阶数为3x=np.linspace(0,1,n_dots)# 在0-1之间生成20个点y=np.s...原创 2019-02-21 14:35:02 · 5299 阅读 · 0 评论 -
python中numpy.eye()函数的学习
numpy.eye(N, M=None, k=0, dtype=&amp;lt;class ‘float’&amp;gt;, order=‘C’)Return a 2-D array with ones on the diagonal and zeros elsewhere. 函数eye()的作用是返回一个对角线diagonal上全是1,而其他位置全为0的一个二维数组(2D-array)。Parameters...翻译 2018-12-29 17:50:33 · 30170 阅读 · 0 评论 -
python学习-numpy.array
2019-12-29 学习numpy中的array函数用法一.在命令行中输入help(numpy.array)得到以下输出help(numpy.array)Help on built-in function array in module numpy.core.multiarray:array(…)array(object, dtype=None, copy=True, order=‘...翻译 2018-12-29 14:19:48 · 314 阅读 · 1 评论 -
Python--编写函数后为什么有个return?
Python中编写函数时有时候会看到代码中有一个return()的语句在Python中定义一个函数时可以在最后加上return返回值,方便查看函数是否运行完成和返回函数的值函数可以不用return,如果没有return返回值,函数返回的值为None函数可以返回数字,字符串,列表,元组,字典,集合;如果返回多个值,则返回的值将以元组返回return语句代表函数执行结束,函数不执行return...原创 2019-02-28 16:47:29 · 2752 阅读 · 0 评论 -
python——Titanic数据集做RandomForest建模分析实验
import pandas as pddef read_dataset(fname):data=pd.read_csv(fname, index_col=0)data.drop([‘Name’,‘Ticket’,‘Cabin’],axis=1,inplace=True)data[‘Sex’]=(data[‘Sex’]==‘male’).astype(‘int’)labels=data[‘...翻译 2019-02-28 17:13:53 · 703 阅读 · 0 评论 -
20190314-python学习笔记(廖雪峰老师python教程)
section——函数:递归函数在函数内部,可以调用其他函数。如果一个函数在内部调用自身本身,这个函数就是递归函数。#阶乘函数def fact(n): if n==1: return 1 return n*fact(n-1)理论上,所有的递归函数都可以写成循环的方式,但循环的逻辑不如递归清晰。**使用递归函数需要注意防止栈溢出。**在计算机中,函...转载 2019-03-14 11:13:57 · 338 阅读 · 0 评论 -
20190306
logistic(客户流失模型?)RFSVM推荐算法(商品推荐)Python中set( )是什么意思set()创建一个 无序不重复的元素集合——A set that is an unordered collection with no duplicate elements。Python中pop(1)是什么意思——列表对应的**pop()**一般是删除掉指定的index对应的值...原创 2019-03-06 22:19:01 · 89 阅读 · 0 评论 -
0311末尾未完成--python学习笔记(resources:廖雪峰老师的python教程)
d={‘Michael’:95, ‘Bob’:75, ‘Tracy’:85}#dictionary用{}括起来,在别的语言中也称之为map,用key-value进行储存,具有极快的查找速度d={‘Michael’:95, ‘Bob’:75, ‘Tracy’:85}d{‘Michael’: 95, ‘Bob’: 75, ‘Tracy’: 85}#这种方法就是在list中查找元素的方法,li...转载 2019-03-14 10:21:13 · 357 阅读 · 0 评论 -
一些片段20190305
对于str:for letter in ‘Python’:print(‘current zimu:’, letter)current zimu: Pcurrent zimu: ycurrent zimu: tcurrent zimu: hcurrent zimu: ocurrent zimu: n对于tuple:对于list:Fruits=[‘banana’,‘a...原创 2019-03-06 20:17:29 · 88 阅读 · 0 评论 -
Python——sklearn包中数据标准化以及缺失值的处理函数汇集
sklearn.preprocessing:博主写的很详细:https://blog.csdn.net/pipisorry/article/details/52247679The preprocessing module further provides a utility class StandardScaler that implements the Transformer API...转载 2019-03-03 19:31:06 · 1991 阅读 · 0 评论 -
python_indexing mechanism to access the elements of arrays
Python has provided a flexible indexing mechanism to access the elements of an array1. 利用索引2. 利用布尔数组原创 2019-02-20 15:03:13 · 125 阅读 · 0 评论 -
自己编写的python模块,使用import导入,以及importlib.reload()函数的使用
在python中使用import命令来带入自己编写的python模块。在调试过程中,如果修改了此模块,则必须使用reload() 函数重新载入该模块。假设我们当前工作目录下面有一个名为function.editing的文件,其内容为:导入模块,并且运行 say_hello()函数:把function.editing文件改为如下的内容并且保存:此时如果仍旧调用say_hello()函...原创 2019-02-20 11:13:21 · 6450 阅读 · 1 评论 -
Python——matplotlib的练习
最简单的示例import matplotlib.pyplot as pltimport matplotlib.pyplot as plt#to draw the sin() curveimport numpy as npx=np.linspace(-np.pi, np.pi, 200)C,S=np.cos(x), np.sin(x)plt.plot(x,C)plt.plot(x,...原创 2019-02-28 20:14:48 · 650 阅读 · 0 评论 -
菜鸟新手python第一个puzzle——sklearn包(scikit-learn包)的斗争安装记录
我是如何在我的python2.7及python3.7分别连接pycharm后给自己成功安装sklearn包的。cmd中pip3指令运行报错解决方法:参考https://blog.csdn.net/cjeric/article/details/73518782,使用如下命令强制重装pip,从而解决了pip报错的问题。python3 -m pip install --upgrade --f...原创 2018-10-14 23:24:19 · 2798 阅读 · 0 评论