美文网首页
python常见 \r \t \n

python常见 \r \t \n

作者: da9b5c100bb7 | 来源:发表于2019-07-30 11:50 被阅读0次

    ···

    import pandas as pd

    import numpy as np

    import matplotlib.pyplot as plt

    from datetime import datetime

    %matplotlib inline

    data=pd.read_csv(r'C:\Users\TAO\Desktop\python-for-data-analysis-master\examples\spx.csv',index_col=0,parse_dates=True)

    data.head()

    a=data['SPX'].idxmin(axis=0,skipna=True)

    spx=data['SPX']

    fig,ax1=plt.subplots(1,1)

    data.plot(ax=ax1,style='g--')

    crsis_data=[(datetime(2007,10,9),'peak of bull matket'),

                (datetime(2008,3,12),'bear fails'),

                (datetime(2008,9,15),'lehamn bankruptcy')]

    for date,label in crsis_data:

        ax1.annotate(label,xy=(date,spx.asof(date)+50),xytext=(date,spx.asof(date)+240),

                    arrowprops=dict(facecolor='black',width=3,headwidth=5),

                    horizontalalignment='left',verticalalignment='top')

    ax1.set_xlim(['1/1/2007','1/1/2011'])

    ax1.set_ylim([600,1800])

    ax1.set_title('important dates in 2008-2009 financial crisis')

    ···

    相关文章

      网友评论

          本文标题:python常见 \r \t \n

          本文链接:https://www.haomeiwen.com/subject/luftkctx.html