python解线性代数
cond 将区间解析–解决报错:ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
当直接写分段函数时
from pylab import *
x = np.linspace(0,10,100)
y =(5*x)*(x<1) + (4*x) * ( 1 <= x <= 3 ) + (0*x+5) * (x>3)
报错说真值只能有一个时
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
用这个替换中间区间就可以运行
x = np.linspace(0,10,100)
cond = [True if (1 <= i <= 3) else False for i in x]
y =(5*x)*(x<1) + (4*x) * cond + (0*x+5) * (x>3)
解方程-- sympy . solve函数实例
from sympy import *
r = Symbol("r") # 重点
P = (r - 0.80853816) / (0.001859637768 - 0.00170 * r)
solve((r - 0.80853816) / (0.001859637768 - 0.00170 * r)-100 , r))
pandas读表格数据画图
df = pd.read_csv('fhjafh.csv')
df.plot.bar()
plt.show()
画的是非常简单的bar图