Path: blob/master/09_Time_Series/Apple_Stock/Exercises-with-solutions-code.ipynb
613 views
Kernel: Python 3
Apple Stock
Check out Apple Stock Exercises Video Tutorial to watch a data scientist go through the exercises
Introduction:
We are going to use Apple's stock price.
Step 1. Import the necessary libraries
In [4]:
Step 2. Import the dataset from this address
Step 3. Assign it to a variable apple
In [32]:
Out[32]:
Step 4. Check out the type of the columns
In [33]:
Out[33]:
Date object
Open float64
High float64
Low float64
Close float64
Volume int64
Adj Close float64
dtype: object
Step 5. Transform the Date column as a datetime type
In [34]:
Out[34]:
0 2014-07-08
1 2014-07-07
2 2014-07-03
3 2014-07-02
4 2014-07-01
Name: Date, dtype: datetime64[ns]
Step 6. Set the date as the index
In [35]:
Out[35]:
Step 7. Is there any duplicate dates?
In [36]:
Out[36]:
True
Step 8. Ops...it seems the index is from the most recent date. Make the first entry the oldest date.
In [39]:
Out[39]:
Step 9. Get the last business day of each month
In [48]:
Out[48]:
Step 10. What is the difference in days between the first day and the oldest
In [65]:
Out[65]:
12261
Step 11. How many months in the data we have?
In [66]:
Out[66]:
404
Step 12. Plot the 'Adj Close' value. Set the size of the figure to 13.5 x 9 inches
In [81]:
Out[81]:
BONUS: Create your own question and answer it.
In [ ]: