1.tile函数的用法
tile函数的用法 tile函数是numpy中用来重复数组的函数,比如tile(A,n),功能是将数组A重复n次,构成一个新的数组。其中n可以是一个数字或一个数组。
2.sum函数
sum(a, axis=None, dtype=None, out=None, keepdims=False)
axis决定数组相加的形式
Examples
--------
>>> np.sum([0.5, 1.5])
2.0
>>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32)
1
>>> np.sum([[0, 1], [0, 5]])
6
>>> np.sum([[0, 1], [0, 5]], axis=0)
array([0, 6])
>>> np.sum([[0, 1], [0, 5]], axis=1)
array([1, 5])
3.字典的get函数
dict.get(key, default=None)
Python 字典(Dictionary) get() 函数返回指定键的值,如果值不在字典中返回默认值
参数
- key -- 字典中要查找的键。
- default -- 如果指定键的值不存在时,返回该默认值。
eg:
dict = {'Name': 'Zara', 'Age': 27}
print "Value : %s" % dict.get('Age')
print "Value : %s" % dict.get('Sex', "Never")
%Value : 27
%Value : Never
4.scatter函数作图
dict = {'Name': 'Zara', 'Age': 27}
print "Value : %s" % dict.get('Age')
print "Value : %s" % dict.get('Sex', "Never")
%Value : 27
%Value : Nevermatplotlib.pyplot.scatter(x, y, s=20, c=None, marker='o', cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None, hold=None, data=None, **kwargs)
x, y : array_like, shape (n, )
Input data 坐标向量
s : scalar or array_like, shape (n, ), optional, default: 20
size in points^2.标记大小
c : color or sequence of color, optional, default标记颜色
5.raw_input()与input()的区别
本文介绍NumPy中的tile和sum函数使用方法,详细解释了Python字典的get函数,并展示了如何使用Matplotlib的scatter函数绘制散点图。同时对比了raw_input()与input()函数的区别。
1457

被折叠的 条评论
为什么被折叠?



