Python Distribution, Packaging and pip
教程
术语
- Python Package Index
Python Package Authority
- 管理机构,一个开发者维护者委员会
distutils(1998)
- 过时的分发工具
setuptools(2004)
- distutils 替代工具
wheel
plotly ---- Python Chart Ploting Library
桑椹图
参考:
代码实践
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36# 实际映射关系 df = pd.DataFrame( [ ['A', 'A', 'A', 'B', 'B', 'B'], ['a', 'b', 'c', 'a', 'b', 'c'], [50, 25, 25, 10, 50, 40]] ) # 输出 0 1 2 0 A a 50 1 A b 25 2 A c 25 3 B a 10 4 B b 50 5 B c 40 # 绘制使用关系(转换后) df = pd.DataFrame( [ [0, 0, 0, 1, 1, 1], [2, 3, 4, 2, 3, 4], [50, 25, 25, 10, 50, 40]] ) # 节点名称到数字映射 A, B ---> [0, 1], a,b,c --->[2,3,4] df = df.T # 绘制 data = go.Sankey(link={'source': df[0], 'target': df[1], 'value': df[2]}, node={'label':list('AB') + list('abc'), 'pad':50, 'thickness':10}) fig = go.Figure(data) fig.show()注意
Graphics Programing编程 图形
教程
html graphics
矩形: (左上角顶点坐标为(x1,y1),右下角顶点坐标为(x2,y2))
1<area shape="rect" coords="x1,y1,x2,y2" href=url>圆形: (圆心坐标为(X1,y1),半径为 r)
1<area shape="circle" coords="x1,y1,r" href=url>多边形: (各顶点坐标依次为(x1,y1)、(x2,y2)、(x3,y3) ……)
scipy ---- Python Scientific Computation Library
线性代数 scipy.linalg
线性方程组
Ax = b
linalg.solve(A, b)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17import numpy as np from scipy import linalg # x + y = 2 # x - y = 4 # 解: x= 3, y = -1 In [100]: A = np.array([[1, 1], ...: [1, -1]]) In [101]: b = np.array([[2], ...: [4]]) ...: In [110]: linalg.solve(A,b) Out[110]: array([[ 3.], [-1.]])
Ax = 0
sympy -- Python Symbolic Compuation Library
矩阵
sympy.Matrix
方法和属性
shape
- mat.shape
- sympy.shape(mat)
list 化
- mat.tolist()
点积
matA * matB
- 和 numpy 不同, np.dot 才可以
创建矩阵
单位阵
- sympy.eye(size)
ones
- sympy.ones(…)
zeros
- sympy.zeros(…)
对角阵
sympy.diag(value1, value2, …)
- 直接输入对角元素
sympy.diag(value1, mat1, mat2, …)