markov_stock_analysis v2-2.py 文件源码

python
阅读 29 收藏 0 点赞 0 评论 0

项目:markov_stock_analysis 作者: nb5hd 项目源码 文件源码
def percent_change_as_time_plot(adjusted_df):
    """
    This function visualizes the percentage change data as a time series plot.

    :param adjusted_df: Pandas DataFrame with columns: Date, Adjusted Close, and Percentage Change.
    """

    pct_change_list = adjusted_df['Percentage Change'].tolist()
    date_list = adjusted_df.index.values
    fig, ax = plt.subplots()
    ax.plot(date_list, pct_change_list)
    #ax.plot(date_list, adjusted_df["Adjusted Close"])
    plt.xlabel("Years")
    plt.ylabel("Percentage change from last week")
    plt.title("Percentage change in S&P 500 weekly data from 2009 to 2016")
    ax.xaxis.set_minor_locator(MonthLocator())
    ax.yaxis.set_minor_locator(MultipleLocator(1))
    ax.fmt_xdata = DateFormatter('%Y-%m-%d')
    ax.autoscale_view()
    fig.autofmt_xdate()

    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号