
python
文章平均质量分 54
heqinglin8
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
scope 命名方法
scope 能让你命名变量的时候轻松很多. 同时也会在 reusing variable 代码中常常见到. 所以今天我们会来讨论下 tensorflow 当中的两种定义 scope 的方式. 最后并附加一个 RNN 运用 reuse variable 的例子.tf.name_scope()tf.variable_scope()RNN应用例子tf.name_scope()在 Tens原创 2017-03-12 22:33:45 · 1163 阅读 · 0 评论 -
python位置
# View more python learning tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.co原创 2017-01-22 00:05:58 · 459 阅读 · 0 评论 -
tkinter框架之frame
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('300x300')frm = tk.Frame(window)frm_l = tk.Frame(frm)frm_l.pack(side='left')frm_r = tk.Frame(frm)frm_r.pack(原创 2017-01-21 23:50:29 · 2876 阅读 · 0 评论 -
tkinter的菜单之menubar
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('300x300')l = tk.Label(window,text="",bg='yellow')l.pack()counter = 0def do_job(): global counter原创 2017-01-21 23:23:58 · 2157 阅读 · 0 评论 -
tkinter之画布
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('300x300')canvas = tk.Canvas(window,bg="blue",width=300,height=200)#image_file = canvas.PhotoImage(file='/baigong.原创 2017-01-21 00:43:42 · 1425 阅读 · 0 评论 -
tkinter的进度条scale(尺子)
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('600x400')var1 = tk.StringVar()label = tk.Label(window,bg='yellow',width=30,heigh=2,text="empty")label.pack()d原创 2017-01-20 23:06:40 · 4172 阅读 · 0 评论 -
pandas的导入导出
#Pandas 导入导出#pandas可以读取与存取的资料格式有很多种,像csv、excel、json、html与pickle等…,#http://pandas.pydata.org/pandas-docs/stable/io.htmlimport pandas as pd#读取csvdata = pd.read_csv('students.csv')print(dat原创 2017-02-20 00:09:03 · 1274 阅读 · 0 评论 -
pandas垃圾数据的处理
# df.dropna() df.fillna() df.isnull() np.any(df.isnull()) == Trueimport numpy as npimport pandas as pddates = pd.date_range('20170326',periods = 6)df = pd.DataFrame(np.arange(24).reshape(6,4)原创 2017-02-19 22:07:04 · 958 阅读 · 0 评论 -
pandas的设置
我们可以根据自己的需求, 用 pandas 进行更改数据里面的值, 或者加上一些空的,或者有数值的列.首先建立了一个 6X4 的矩阵数据。dates = pd.date_range('20130101', periods=6)df = pd.DataFrame(np.arange(24).reshape((6,4)),index=dates, columns=['A','B','C'转载 2017-02-19 17:19:26 · 443 阅读 · 0 评论 -
Radiobutton
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('300x400')var1 = tk.StringVar()label = tk.Label(window,bg='yellow',width=10,heigh=2,text="empty")label.pack()d原创 2017-01-20 00:14:31 · 344 阅读 · 0 评论 -
ListBox
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('200x400')var1 = tk.StringVar()label = tk.Label(window,bg='yellow',width=6,heigh=2,textvariable=var1)label.pack(原创 2017-01-19 23:51:08 · 300 阅读 · 0 评论 -
tkinter之entry和text
import tkinter as tkwindow = tk.Tk()window.title("我的窗口")window.geometry('200x200')ent = tk.Entry(window,show = '*')ent.pack()def insertPoint(): var = ent.get() text.insert(原创 2017-01-19 22:48:29 · 1057 阅读 · 0 评论 -
pandas的合并
import pandas as pdimport numpy as np#定义资料集df1 = pd.DataFrame(np.ones((3,4))*0, columns=['a','b','c','d'])df2 = pd.DataFrame(np.ones((3,4))*1, columns=['a','b','c','d'])df3 = pd.DataFrame(原创 2017-02-21 00:23:36 · 467 阅读 · 0 评论 -
存储进程输出 Queue
import multiprocessing as mpimport threading as tddef job(q): res = 0 for i in range(1000): res+= i+i**2+i**3 q.put(res)if __name__ == '__main__': q = mp.Queue()原创 2017-02-12 21:33:49 · 681 阅读 · 0 评论 -
进程池 Pool
import multiprocessing as mpimport threading as tddef job(x): return x*xdef multicore(): pool = mp.Pool(processes = 1) res = pool.map(job,range(10000000)) print(res)原创 2017-02-12 21:36:04 · 564 阅读 · 0 评论 -
tensorflow结果可视化
# View more python learning tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.co原创 2017-03-04 14:53:59 · 1523 阅读 · 0 评论 -
tensorflow 建造神经层
# View more python learning tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.co原创 2017-03-04 12:07:08 · 490 阅读 · 0 评论 -
numpy 的关联性
# numpy 的关联性#Numpy copy & deep copyimport numpy as npa = np.arange(4)print(a)# =带来的赋值会带来关联性b = ac = ad = bprint(b,c,d)a[3] = 88print(a,b,c,d)print(a == d)#copy()的赋值方式没有关联性原创 2017-02-16 00:23:12 · 428 阅读 · 0 评论 -
Numpy array 分割
#Numpy array 分割import numpy as np#建立3行4列arrayA = np.arange(16).reshape(4,4)print(A)"""[[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11]] """# 纵向分割print(np.split(A,2,axis = 1))#横向分原创 2017-02-15 00:14:06 · 3371 阅读 · 0 评论 -
Numpy array 合并
对于一个array的合并,我们可以想到按行、按列等多种方式进行合并。首先先看一个例子:import numpy as np# numpy合并a = np.array([1,1,1])b = np.array([2,2,2])print(np.vstack((a,b))) # 竖向合并"""[[1,1,1] [2,2,2]]"""print(np原创 2017-02-14 23:56:52 · 662 阅读 · 0 评论 -
一个简单的登陆系统
# View more python learning tutorial on my Youtube and Youku channel!!!# Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg# Youku video tutorial: http://i.youku.co原创 2017-01-24 17:00:01 · 1064 阅读 · 0 评论 -
Pandas plot 出图
#pandas中的merge和concat类似,但主要是用于两组有key column的数据,#统一索引的数据. 通常也被用在Database的处理当中.from __future__ import print_functionimport pandas as pdimport numpy as npimport matplotlib.pyplot as plt'''#原创 2017-02-22 00:13:50 · 997 阅读 · 0 评论 -
Numpy 索引
import numpy as np#我们都知道,在元素列表或者数组中,我们可以用如同a[2]一样的表示方法,同样的,在Numpy中也有相对应的表示方法:A = np.arange(3,15)# array([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])print(A)range(3,15) #生成一个range object原创 2017-02-13 19:10:45 · 535 阅读 · 0 评论 -
Numpy 基础运算2
通过上一节的学习,我们可以了解到一部分矩阵中元素的计算和查找操作。然而在日常使用中,对应元素的索引也是非常重要的。依然,让我们先从一个脚本开始 :import numpy as npA = np.arange(2,14).reshape((3,4)) # array([[ 2, 3, 4, 5]# [ 6, 7, 8, 9]# [10,11,12原创 2017-02-13 00:53:58 · 1810 阅读 · 0 评论 -
numpy基础运算1
import numpy as npa = np.array([1,2,3,4])b = np.arange(4)print(a)print(b)print(a-b)print(a+b)print(a*b)print(b**2)print(b>2)print('************************************')c_dot原创 2017-02-13 00:24:39 · 368 阅读 · 0 评论 -
python的进程锁
import multiprocessing as mpimport threading as tdimport timedef job(v,num,l): l.acquire() for _ in range(10): time.sleep(0.1) v.value += num print(v.value原创 2017-02-12 21:37:05 · 831 阅读 · 0 评论 -
Pandas 选择数据
pandas 中选择数据的方法有很多种,一般我们会用到这几种.简单的筛选根据标签: loc根据序列: iloc根据混合的这两种: ix还有通过判断的筛选我们建立了一个 6X4 的矩阵数据。dates = pd.date_range('20130101', periods=6)df = pd.DataFrame(np.arange(24).reshape((6,4)转载 2017-02-18 23:11:30 · 3340 阅读 · 0 评论 -
pandas的基础应用
import pandas as pdimport numpy as np# series 的使用方法s = pd.Series([1,3,6,np.nan,44,1])print(s)print(s.dtype)#DataFrame 的创建:dates= pd.date_range('20170101',periods=6)df = pd.DataFr原创 2017-02-18 21:17:07 · 412 阅读 · 0 评论 -
tkinter的应用
import tkinter as tkwindow = tk.Tk()window.title("我的第一个视窗")window.geometry("200x100")# 这里显示视窗内容var = tk.StringVar()label = tk.Label(window,textvariable=var,font=('Arial',12),bg = 'yel原创 2017-01-18 00:44:20 · 556 阅读 · 0 评论 -
input 输入
# if str.isdigit(): 判断输入为数字score = input('please input a score: \n')if score.isdigit(): score = int(score) if score >= 90: print('你的等级是:A') elif score >= 80: print原创 2017-01-14 21:46:22 · 443 阅读 · 0 评论 -
class 类 init 功能(类似java类的构造函数)
_init__可以理解成初始化class的变量,取自英文中initial 最初的意思.可以在运行时,给初始值附值,运行c=Calculator('bad calculator',18,17,16,15),然后调出每个初始值的值。看如下代码。# python 的面向对象的用法实例 __init__是用来初始化类的一些变量的,类似于java的构造方法class Person:原创 2017-01-14 20:45:31 · 5947 阅读 · 0 评论 -
文件读写
#文件操作# 写入# text = 'this is first line \n this is second line \n this is last line'# myfile = open('my_file.txt','w')# myfile.write(text)# myfile.close()# 给文件添加内容 'a'=append 以增加内容的形式打开add原创 2017-01-14 20:35:02 · 632 阅读 · 0 评论 -
python的面向对象
class 类class 定义一个类, 后面的类别首字母推荐以大写的形式定义,比如Calculator.class可以先定义自己的属性,比如该属性的名称可以写为name='Good Calculator'.class后面还可以跟def, 定义一个函数.比如def add(self,x,y): 加法, 输出print(x+y).其他的函数定义方法一样,注意这里的self 是默认值.#原创 2017-01-14 20:31:43 · 250 阅读 · 0 评论 -
Python 外部模块numpy安装
安装numpysudo pip3 install numpy升级numpysudo pip3 install -U numpy原创 2017-01-14 16:39:24 · 550 阅读 · 0 评论 -
全局和局部变量
#全局和局部变量APPLE = 100a = Nonedef fun(): #global APPLE a = 20 APPLE = 88 return a+100print(APPLE)print('a past=',a)print(fun())print('a now=',a)print('APPLE now is',AP原创 2017-01-14 16:22:41 · 331 阅读 · 0 评论 -
def定义函数
# def 函数def function(a,b): return a+bprint("this is func result:")print(function(2,3))print("this is func result:",function(3,5))#默认函数参数def saleCar(price,color="red",brand="dazh原创 2017-01-14 16:01:31 · 3563 阅读 · 0 评论 -
if语句的使用
# if语句的使用x = -1y = 2z = 3i = 3if x>y: print('x is greater than y')elif x print('x is 小于 0')elif x print('x is less to y')else: print('x is equal to y')print('##原创 2017-01-14 15:30:15 · 580 阅读 · 0 评论 -
for循环
# for 迭代数组array = [1,3,5,7,9,118,18,81]for i in array: print(i) print('in for')print('out of for')print('############ range ###############')for j in range(1,10,2): prin原创 2017-01-14 15:01:52 · 638 阅读 · 0 评论 -
变量 variable
1、自变量命名规则>>> apple = 7 ##赋值 数字>>> print(apple)7>>> apple = 'phone is 7 plus'>>> print(apple)phone is 7 plus>>> print(apple+1)Traceback (most recent call last): File "", line 1, in原创 2017-01-14 12:13:57 · 383 阅读 · 0 评论 -
基础数学运算
1、 加减乘除>>> 1+12>>> 4-13>>> 3*412>>> 4/31.3333333333333333>>> 4//31>>> 4//3 #整出 3 最近的整数1>>> 2、^符号与**python当中^符号,区别于Matlab,在python中,^用两个**表示,如3的平方为3**2 , **3表示立方,**原创 2017-01-14 12:01:27 · 436 阅读 · 0 评论