gpt4 book ai didi

python - Pandas 不绘制代码。

转载 作者:太空宇宙 更新时间:2023-11-03 14:57:38 26 4
gpt4 key购买 nike

我是编码新手,正在尝试通过代码来理解 Quantopian 的讲座,但是当我在 PyCharm 中运行代码时,没有输出。有人可以告诉我发生了什么事并建议我如何解决这个问题吗?

下面是我的一段代码(2.7.13):

import numpy as np
import pandas as pd

import statsmodels
import statsmodels.api as sm
from statsmodels.tsa.stattools import coint
# just set the seed for the random number generator
np.random.seed(107)

import matplotlib.pyplot as plt

X_returns = np.random.normal(0, 1, 100) # Generate the daily returns
# sum them and shift all the prices up into a reasonable range
X = pd.Series(np.cumsum(X_returns), name='X') + 50
X.plot();

当我运行此命令时,唯一的输出是:“进程已完成,退出代码为 0”

最佳答案

只需在末尾添加 plt.show() 即可:

import numpy as np
import pandas as pd

import statsmodels
import statsmodels.api as sm
from statsmodels.tsa.stattools import coint
# just set the seed for the random number generator
np.random.seed(107)

import matplotlib.pyplot as plt

X_returns = np.random.normal(0, 1, 100) # Generate the daily returns
# sum them and shift all the prices up into a reasonable range
X = pd.Series(np.cumsum(X_returns), name='X') + 50
X.plot()
plt.show()

关于python - Pandas 不绘制代码。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45396727/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com