随笔分类 -  python

上一页 1 2 3 下一页
图标位置
摘要:True 阅读全文
posted @ 2018-03-09 19:53 郑哲 阅读(177) 评论(0) 推荐(0)
柱形图
摘要:用线性数据画柱状图 1 plt.figure() 2 xvals = range(len(linear_data)) 3 plt.bar(xvals, linear_data, width = 0.3) 4 5 new_xvals = [] 6 7 # 创建new_xvals使横坐标向右移动0.3,用平方数据画红色的柱状图 8 for item in xvals: 9 ... 阅读全文
posted @ 2018-03-09 19:41 郑哲 阅读(203) 评论(0) 推荐(0)
Plots画线
摘要:错误代码 阅读全文
posted @ 2018-03-09 19:22 郑哲 阅读(183) 评论(0) 推荐(0)
Scatterplots画点
摘要:1 import numpy as np 2 3 x = np.array([1,2,3,4,5,6,7,8]) 4 y = x 5 6 plt.figure() 7 plt.scatter(x, y) # similar to plt.plot(x, y, '.'), but the underlying child objects in the axes are not Line2D ... 阅读全文
posted @ 2018-03-09 18:47 郑哲 阅读(690) 评论(0) 推荐(0)
matplotlib基础画线
摘要:%%html<img src='test.png' /> 阅读全文
posted @ 2018-03-06 15:38 郑哲 阅读(317) 评论(0) 推荐(0)
数据拷贝
摘要:1 r2 = r[:3,:3] 2 r2 array([[ 0, 1, 2], [ 6, 7, 8], [12, 13, 14]]) 1 r2[:] = 0 2 r2 array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])此时r= array([[ 0, 0, 0, 3, 阅读全文
posted @ 2018-03-05 20:27 郑哲 阅读(190) 评论(0) 推荐(0)
数组索引
摘要:1 s = np.arange(13)**2 2 s array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) 1 s[0], s[4], s[-1] (0, 16, 144) 1 s[1:5] array([ 1, 4, 9, 16]) 阅读全文
posted @ 2018-03-05 20:24 郑哲 阅读(205) 评论(0) 推荐(0)
数组函数
摘要:1 a = np.array([-4, -2, 1, 3, 5]) 2 a.sum() 3 1 a.max() 5 1 a.min() -4 1 a.mean() 0.60 1 a.std() 3.26 1 a.argmax() 4 1 a.argmin() 0 阅读全文
posted @ 2018-03-05 20:19 郑哲 阅读(108) 评论(0) 推荐(0)
数组操作符
摘要:1 print(x + y) # elementwise addition [1 2 3] + [4 5 6] = [5 7 9] 2 print(x - y) # elementwise subtraction [1 2 3] - [4 5 6] = [-3 -3 -3] [5 7 9] [-3 阅读全文
posted @ 2018-03-05 20:17 郑哲 阅读(122) 评论(0) 推荐(0)
numpy
摘要:1 import numpy as np %通过链表创建数组1 mylist = [1, 2, 3] 2 x = np.array(mylist) 3 x array([1, 2, 3]) %直接创建数组1 y = np.array([4, 5, 6]) 2 y array([4, 5, 6]) %创建多维数组1 m = np.array([[7, 8, 9], [10, 11,... 阅读全文
posted @ 2018-03-05 20:13 郑哲 阅读(117) 评论(0) 推荐(0)
λ和列表解析
摘要:%下面是lambda的示例,它包含三个参数并添加前两个参数。1 my_function = lambda a, b, c : a + b 2 my_function(1, 2, 3) 3 1 my_list = [] 2 for number in range(0, 1000): 3 if numb 阅读全文
posted @ 2018-03-05 20:03 郑哲 阅读(118) 评论(0) 推荐(0)
object和map
摘要:1 class Person: 2 department = 'School of Information' #a class variable 3 4 def set_name(self, new_name): #a method 5 self.name = new_name 6 def set_ 阅读全文
posted @ 2018-03-05 20:00 郑哲 阅读(116) 评论(0) 推荐(0)
日期Dates时间Times
摘要:1 import datetime as dt 2 import time as tm %时间从纪元开始以秒为单位返回当前时间。(1970年1月1日)1 tm.time() 1520242063.03 1 dtnow = dt.datetime.fromtimestamp(tm.time()) 2 阅读全文
posted @ 2018-03-05 19:56 郑哲 阅读(276) 评论(0) 推荐(0)
csv文件的读写
摘要:Let's import our datafile mpg.csv, which contains fuel economy data for 234 cars. mpg : miles per gallon class : car classification cty : city mpg cyl 阅读全文
posted @ 2018-03-05 19:53 郑哲 阅读(510) 评论(0) 推荐(0)
更多关于字符串string
摘要:1 print('Chris' + 2) TypeError Traceback (most recent call last) <ipython-input-37-82ccfdd3d5d3> in <module>() > 1 print('Chris' + 2) TypeError: must 阅读全文
posted @ 2018-03-05 19:32 郑哲 阅读(117) 评论(0) 推荐(0)
解压序列
摘要:%解压序列到不同的变量中1 x = ('Christopher', 'Brooks', 'brooksch@umich.edu') 2 fname, lname, email = x 1 fname 'Christopher' 1 lname 'Brooks' %确保变量的数量和解压的值相同1 x = ('Christopher', 'Brooks', 'brooksch@umi... 阅读全文
posted @ 2018-03-05 19:30 郑哲 阅读(77) 评论(0) 推荐(0)
字典
摘要:%字典用keys来连接values1 x = {'Christopher Brooks': 'brooksch@umich.edu', 'Bill Gates': 'billg@microsoft.com'} 2 x['Christopher Brooks'] # Retrieve a value 阅读全文
posted @ 2018-03-05 19:28 郑哲 阅读(92) 评论(0) 推荐(0)
链表list和字符串string
摘要:list 阅读全文
posted @ 2018-03-05 19:20 郑哲 阅读(158) 评论(0) 推荐(0)
python类型和序列
摘要:NoneType int float function 阅读全文
posted @ 2018-03-05 18:51 郑哲 阅读(117) 评论(0) 推荐(0)
元组
摘要:tuple 阅读全文
posted @ 2018-03-05 18:51 郑哲 阅读(77) 评论(0) 推荐(0)

上一页 1 2 3 下一页