- 博客(35)
- 收藏
- 关注
原创 由二维矩阵画散点图
横纵坐标分别为x, y矩阵各个点的值作为由不同的颜色区分出来二维 + 一维颜色#!/usr/bin/env python# coding: utf-8import numpy as npimport matplotlib.pyplot as pltfig = plt.figure(figsize=(12, 8))ax = fig.add_subplot(111)plt.st...
2019-04-16 16:35:47
3099
原创 python - from collections import deque
常用的几个方法的介绍(来自《python cookbook》)注意事项1.extendleft 是迭代入队而 appendleft 不是2.可以取索引值,但是没有切片
2019-04-14 18:23:48
4482
原创 队列 计算机打印任务模拟
import osimport randomfrom collections import dequeclass Printer: def __init__(self, ppm): self.pagerate = ppm#每分钟打印多少页 self.currentTask = None self.timeRemaining = 0...
2019-04-14 17:47:16
732
原创 牛客网python刷题遇到问题
1.输入输出:1.输入读取示例和说明2.论坛关于多行输入的讨论可行方案2.本地调试正确而在线提交错误的可能原因博文原址
2019-04-13 17:14:50
679
原创 AttributeError: 'Polar AxesSubplot' object has no attribute 'set_axis_bgcolor'
是matplotlib库升级导致,我把库恢复到以前版本就可以运行了It looks like ‘set_axis_bgcolor’ should be replaced with ‘facecolor’.也可以尝试把方法set_axis_bgcolor改成facecolor,试试gitHub讨论1github讨论2...
2019-04-13 10:44:41
9405
1
原创 641. Design Circular Deque [LeetCode]
英文网址中文网址我的解答20190412class MyCircularDeque(object): def __init__(self, k): """ Initialize your data structure here. Set the size of the deque to be k. :type k: int ...
2019-04-12 17:25:34
112
原创 8.np.bincount()
1.使用说明2.weights权重原本默认序号是0-n,现在通过设置wieghts参数指定对应的权值。如果值n发现在位置i,那么out[n] += weight[i]而不是out[n] += 1。weights的大小必须与x相同,否则报错。比如3出现x的第[2]和[5],故np.bincount产生的数组的第[3]值计算如图w[2]+w[5]=…。3.minlength很好理解,...
2019-02-01 14:15:43
156
原创 5.散点图矩阵 pd.plotting.scatter_matrix
pd.plotting.scatter_matrix(iris_dataframe, c=y_train, figsize=(15,15), marker=‘0’, hist_kwds={‘bins’:50},s=60,alpha=.8, cmap=mglearn.cm3)结果:pd.scatter_matrix若不可用。用pd.plotting.scatter_matrix替换掉pd....
2019-01-30 17:14:18
14018
1
原创 4.np.random.multivariate_normal()
根据实际情况生成一个多元正态分布矩阵def multivariate_normal(mean, cov, size=None, check_valid=None, tol=None)详细:https://blog.csdn.net/zch1990s/article/details/80005940
2019-01-30 16:48:03
672
原创 3.pd.get_dummies(Data,prefix=**)
3.pd.get_dummies(Data,prefix=**)定性变量转换为虚拟变量。pandas.get_dummies(data, prefix=None, prefix_sep=’_’, dummy_na=False, columns=None, sparse=False, drop_first=False)
2019-01-25 16:09:45
2896
原创 2.dataframe.shape()
2.dataframe.shape()返回形状,即几行几列的数组,如[2,3],shape[0]=rows,shape[1]=columns
2019-01-25 16:09:00
22250
原创 1.dataframe groupby()
1.dataframe groupby()返回值:返回重构格式的DataFrame,groupby里面的字段内的数据重构后都会变成索引
2019-01-25 16:08:18
1009
原创 7.np.sum(a, axis=1, keepdims=True)
7.np.sum(a, axis=1, keepdims=True)axis=1 以竖轴为基准 ,同行相加keepdims主要用于保持矩阵的二维特性
2019-01-25 16:03:23
8476
2
原创 6. np.random.uniform
6.np.random.uniform(来自:https://blog.csdn.net/u013920434/article/details/52507173 )
2019-01-25 16:02:49
379
原创 4.numpy.ravel() vs numpy.flatten()
4.numpy.ravel() vs numpy.flatten()来自https://blog.csdn.net/lanchunhui/article/details/50354978两者所要实现的功能是一致的(将多维数组降位一维),两者的区别在于返回拷贝(copy)还是返回视图(view),numpy.flatten()返回一份拷贝,对拷贝所做的修改不会影响原始矩阵,而numpy.rave...
2019-01-25 16:00:42
153
原创 3.np.meshgrid(x,y)
3.np.meshgrid(x,y)(图例来自:https://www.jianshu.com/p/99ade8578844)总结一下:比如x有4个元素,y有3个元素,故生成的矩阵为3行4列的矩阵,形状固定,矩阵z,s的元素对应x,y本身元素的复制,但x作为z的行向量,y作为s的列向量。...
2019-01-25 16:00:02
1480
原创 2.np.r_,np.c_
2.np.r_,np.c_np.r_ 按列拼接矩阵(要求列数相同)(numpy 一维数组虽然横着表示,但是它是列向量)np.c_ 按行拼接矩阵(要求行数相同)
2019-01-25 15:59:24
111
原创 1.matplotlib.pyplot里contour
可视化函数1.matplotlib.pyplot里contour画等高线def visualize(data, C, res): """ 将模型结果可视化 """ # 创建一个图形框 fig = plt.figure(figsize=(12, 6), dpi=80) # 在图形框里画
2019-01-25 11:40:59
781
原创 1.np.concatenate()
1.np.concatenate()基于numpy库concatenate是一个非常好用的数组操作函数
2019-01-23 10:25:42
1549
2
转载 正则表达式
[原创文章,转载请保留或注明出处:http://www.regexlab.com/zh/regref.htm]引言 正则表达式(regular expression)就是用一个“字符串”来描述一个特征...
2018-08-31 22:36:44
69
转载 转载博客
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41652274/article/details/79248848 ...
2018-08-31 22:32:06
132
原创 wxpython 5.1 重构后的代码 RefactorExample2
#!/usr/bin/env python#-*- coding:utf-8 -*-import wx class RefactorExample(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'ReFactor Example', ...
2018-07-26 11:35:43
94
原创 wxpython 5.1 待重构的一串代码 RefactorExample
#!/usr/bin/env python#-*- coding:utf-8 -*-import wx class RefactorExample(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'ReFactor Example', ...
2018-07-26 09:59:01
98
原创 AppendSeparator() wxpython 菜单分隔符
*** pasteItem=menu2.Append(-1,"Paste","Paste")self.Bind(wx.EVT_MENU,self.OnPaste,pasteItem) menu2.AppendSeparator()optItem=menu2.Append(-1,"&Option...","Display Options")self.Bin...
2018-07-26 09:40:37
1092
原创 wxpython 3.6 创建自定义事件(点击计数) CustomEventFrame
#!/usr/bin/env python#-*-coding:utf-8 -*-import wxclass TwoButtonEvent(wx.PyCommandEvent): def __init__(self,evtType,id): wx.PyCommandEvent.__init__(self,evtType,id) self.cli...
2018-07-24 16:37:39
512
原创 wxpython 3.4 同时响应鼠标按下和按钮敲击DoubleEventFrame
#!/usr/bin/env python#-*- coding:utf-8 -*-import wxclass DoubleEventFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Frame with button', ...
2018-07-24 11:27:19
194
原创 wxpython 3.4 绑定多个鼠标事件MouseEventFrame
#!/usr/bin/env python#-*- coding:utf-8 -*-import wxclass MouseEventFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Frame With Button', ...
2018-07-24 10:47:22
663
原创 wxpython 3.3 MenuEventFrame
#!/usr/bin/env python#-*- coding:utf-8 -*-import wxclass MenuEventFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Menus', s...
2018-07-23 17:29:58
128
原创 wxpython 2.7 列表选择窗口 SingleChoiceDialog
#!/usr/bin/env python#-*-coding:UTF-8 -*-import wxif __name__=='__main__': app=wx.PySimpleApp() frame=wx.SingleChoiceDialog(None, 'What version of Python ...
2018-07-21 15:52:38
401
原创 wxpython 2.7 文本输入对话框 TextEntryDialog
#!/usr/bin/env python#-*-coding:UTF-8 -*-import wxif __name__=='__main__': app=wx.PySimpleApp() frame=wx.TextEntryDialog(None,"who is buried in Grant's tomb?", ...
2018-07-21 15:41:52
845
原创 wxpython 2.7 简单消息对话框(是/否 ;ok)MessageDialog
#!/usr/bin/env python#-*-coding:UTF-8 -*-import wxif __name__=='__main__': app=wx.PySimpleApp() frame=wx.MessageDialog(None,'Is this the coolest thing ever!', 'Messa...
2018-07-21 15:21:01
1098
原创 wxPython 2.6.2 框架增加菜单、工具、状态栏 ToolBarFrame
#!/usr/bin/env python#-*-coding:UTF-8 -*-import wximport wx.py.images as imagesclass ToolbarFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'To...
2018-07-21 14:53:07
496
原创 wxpython 2.6.1 给框架增加窗口部件
#!/usr/bin/env pythonimport wxclass InsertFrame(wx.Frame): def __init__(self,parent,id): wx.Frame.__init__(self,parent,id,'Frame With Button', size=(300...
2018-07-21 11:41:14
249
原创 wxpython2.3.1重定向输出
#!/usr/bin/env pythonimport wximport sys class Frame(wx.Frame): def __init__(self,parent,id,title): print 'Frame__init__' wx.Frame.__init__(self,parent,id,title)cla...
2018-07-21 09:37:24
339
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人