使 plt.plot 遍历原点的代码
我有一个名为 df 的 Pandas 数据框,只有 2 列数字:x 和 y。 为了使最适合的行穿过原点,我编写了这行代码:
x=df.iloc[1:28,0]
lst_sq_x=df.iloc[1:28,0].values.reshape(-1,1)
lst_sq_y=df.iloc[1:28,1]
plt.plot(x, np.linalg.lstsq(lst_sq_x, lst_sq_y)[0][0])(x))
但是,这行代码不起作用(语法无效)。你能告诉我我做错了什么吗?
I have a Pandas data frame called df with only 2 columns of numbers: x and y.
To make the line of best fit go through the origin, I have made this line of code:
x=df.iloc[1:28,0]
lst_sq_x=df.iloc[1:28,0].values.reshape(-1,1)
lst_sq_y=df.iloc[1:28,1]
plt.plot(x, np.linalg.lstsq(lst_sq_x, lst_sq_y)[0][0])(x))
However, this line does not work (invalid syntax). Will you tell me what I'm getting wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论