コード例 #1
0
def plot_bitcoin():
    """Plot BitCoin prices and a smoothed time series.
    """
    nrows = 1625
    df = pandas.read_csv('coindesk-bpi-USD-close.csv', 
                         nrows=nrows, parse_dates=[0])
    ys = df.Close.values

    window = np.ones(30)
    window /= sum(window)
    smoothed = np.convolve(ys, window, mode='valid')

    N = len(window)
    smoothed = thinkdsp.shift_right(smoothed, N//2)

    thinkplot.plot(ys, color='0.7', label='daily')
    thinkplot.plot(smoothed, label='30 day average')
    thinkplot.config(xlabel='time (days)', 
                     ylabel='price',
                     xlim=[0, nrows],
                     loc='lower right')
    thinkplot.save(root='convolution1')
コード例 #2
0
ファイル: convolution.py プロジェクト: younlonglin/ThinkDSP
def plot_bitcoin():
    nrows = 1625
    df = pandas.read_csv("coindesk-bpi-USD-close.csv", nrows=nrows, parse_dates=[0])
    ys = df.Close.values

    window = numpy.ones(30)
    window /= sum(window)
    smoothed = numpy.convolve(ys, window, mode="valid")

    N = len(window)
    smoothed = thinkdsp.shift_right(smoothed, N // 2)

    thinkplot.plot(ys, color="0.7", label="daily")
    thinkplot.plot(smoothed, label="30 day average")
    thinkplot.config(
        xlabel="time (days)",
        ylabel="price",
        xlim=[0, nrows],
        #                     ylim=[-60, 60],
        loc="lower right",
    )
    thinkplot.save(root="convolution1")
コード例 #3
0
ファイル: convolution.py プロジェクト: AllenDowney/ThinkDSP
def plot_bitcoin():
    """Plot BitCoin prices and a smoothed time series.
    """
    nrows = 1625
    df = pandas.read_csv('coindesk-bpi-USD-close.csv', 
                         nrows=nrows, parse_dates=[0])
    ys = df.Close.values

    window = np.ones(30)
    window /= sum(window)
    smoothed = np.convolve(ys, window, mode='valid')

    N = len(window)
    smoothed = thinkdsp.shift_right(smoothed, N//2)

    thinkplot.plot(ys, color='0.7', label='daily')
    thinkplot.plot(smoothed, label='30 day average')
    thinkplot.config(xlabel='time (days)', 
                     ylabel='price',
                     xlim=[0, nrows],
                     loc='lower right')
    thinkplot.save(root='convolution1')