NumPy库
random.rand(4,4)
array([[ 0.50644331, 0.44375774, 0.79081 , 0.73889543],
[ 0.69320171, 0.64640474, 0.96746222, 0.99856647],
[ 0.26621224, 0.42479067, 0.65365039, 0.23237977],
[ 0.81672981, 0.53695627, 0.36692742, 0.9787382 ]])
mat(random.rand(4,4))
matrix([[ 0.91275385, 0.54632161, 0.25685307, 0.62581389],
[ 0.62642073, 0.31651896, 0.75398169, 0.17982347],
[ 0.72390911, 0.16819123, 0.18983078, 0.59421625],
[ 0.80979891, 0.17644632, 0.81972653, 0.20486715]])
Mat.I矩阵求逆
eye(4)
import matplotlib.pyplot as plt
plt.title("hw1,")
plt.xlim(xmax=100,xmin=0)
plt.ylim(ymax=120,ymin=0)
plt.xlabel("x")
plt.ylabel("y")
plt.plot(x,y,'ro',t,t+1,'ro')
plt.show()
计算相关系数
x=100*random.rand(50)
y=x+1
s1=Series(x)
s2=Series(y)
cor=s1.corr(s2)#计算相关系数
1.split()方法
a = ‘www.baidu.com’
print(a.split(‘.’))
result [‘www’, ‘baidu’, ‘com’]
2.repalce()方法
a = ‘There is apples’
b = a.replace(‘is’,’are’)
print(b)
result There are apples
3.strip()方法
a = ’ python is cool ’
print(a.strip())
result python is cool
strip()方法返回去除两侧(不包括内部)空格的字符串,也可以指定需要去除的字符,将他们列为参数中即可。
4.format()方法
最后,再讲解下好用的字符串格式化符,首先看下代码。
a = ‘{} is my love’.format(‘Python’)
print(a)