Package Installation

In [6]:
pip install pandas
Requirement already satisfied: pandas in /srv/conda/envs/notebook/lib/python3.6/site-packages (1.1.4)
Requirement already satisfied: python-dateutil>=2.7.3 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas) (2020.4)
Requirement already satisfied: numpy>=1.15.4 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas) (1.19.4)
Requirement already satisfied: six>=1.5 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Note: you may need to restart the kernel to use updated packages.
In [7]:
pip install pandas-datareader
Requirement already satisfied: pandas-datareader in /srv/conda/envs/notebook/lib/python3.6/site-packages (0.9.0)
Requirement already satisfied: lxml in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas-datareader) (4.6.1)
Requirement already satisfied: requests>=2.19.0 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas-datareader) (2.24.0)
Requirement already satisfied: pandas>=0.23 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas-datareader) (1.1.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from requests>=2.19.0->pandas-datareader) (1.25.10)
Requirement already satisfied: certifi>=2017.4.17 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from requests>=2.19.0->pandas-datareader) (2020.6.20)
Requirement already satisfied: chardet<4,>=3.0.2 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from requests>=2.19.0->pandas-datareader) (3.0.4)
Requirement already satisfied: idna<3,>=2.5 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from requests>=2.19.0->pandas-datareader) (2.10)
Requirement already satisfied: python-dateutil>=2.7.3 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas>=0.23->pandas-datareader) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas>=0.23->pandas-datareader) (2020.4)
Requirement already satisfied: numpy>=1.15.4 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from pandas>=0.23->pandas-datareader) (1.19.4)
Requirement already satisfied: six>=1.5 in /srv/conda/envs/notebook/lib/python3.6/site-packages (from python-dateutil>=2.7.3->pandas>=0.23->pandas-datareader) (1.15.0)
Note: you may need to restart the kernel to use updated packages.

Data Acquisition

First, we need to import the packages and modules.

In [8]:
import pandas as pd
from pandas_datareader import data
import matplotlib.pyplot as plt
from pandas.plotting import register_matplotlib_converters
register_matplotlib_converters()

Now we define the company we want to look at through their associated shortcut and we set the starting date and the ending date.

In [9]:
symbol = 'NFLX'
data_source = 'yahoo'
start_date = '2020-01-01'
end_date = '2020-09-30'

We now try to extract the data from the yahoo finance website.

In [10]:
df = data.get_data_yahoo(symbol, start_date, end_date)

df.index = pd.to_datetime(df.index)
print(type(df.index))
<class 'pandas.core.indexes.datetimes.DatetimeIndex'>

We now check if there are some null values.

In [11]:
print(df.isnull().sum()) 
High         0
Low          0
Open         0
Close        0
Volume       0
Adj Close    0
dtype: int64

Fortunately, there are no null values. We now can plot a graph that shows us our extracted data.

In [12]:
fig, ax = plt.subplots(figsize=(12, 6))
ax.plot_date(x= df.index, y = df['Adj Close'], fmt='-')
fig.suptitle('NFLX')
plt.show()