In [51]:
import pandas as pd
from matplotlib import pyplot as plt
import numpy as np
import datetime
In [10]:
def plot_coords(filename):
    df = pd.read_csv(filename, header=None)
    plt.plot(df[0],df[1],'.')
In [13]:
plot_coords('coordinates_3.txt')
In [15]:
plot_coords('regression_coordinates_1.txt')
In [30]:
def plot_linear_regression(filename):
    df = pd.read_csv(
        filename, header=None
    )
    m, b = np.polyfit(df[0], df[1], deg=1)
    line_x = np.arange(df[0].min(), df[0].max(), 0.5)
    line_y = m * line_x + b 
    plot_coords(filename)
    plt.plot(line_x, line_y)
In [68]:
plot_linear_regression('regression_coordinates_1.txt')
In [ ]:
def read_and_plot(filename):
    df = pd.read_csv(filename)
    df['Low'] = df['Low'].str.replace('$', '').astype(float)
    df['Date'] = pd.to_datetime(df['Date'], format='%m/%d/%Y')
    plt.plot(df['Date'], df['Low'])
    plt.xlabel('Time')
    plt.ylabel('Low')
In [67]:
read_and_plot('AAPL_5Y.csv')
read_and_plot('GME_5Y.csv')
plt.title('AAPL vs. GME 5Y')
plt.legend(['AAPL', 'GME'])
Out[67]:
<matplotlib.legend.Legend at 0x28705d07190>