Open duncangh opened 7 years ago
Thanks @duncangh, much appreciated! We'll review this and I'm sure it will benefit from your feedback.
Hi @duncangh thanks for the feedback! You're correct - the plot was wrong.
I agree .pct_change()
is a cool method, although in this example it's a little tricky to use as we want to calculate it for only the first and last day of 2013. Your method works well, however it becomes tricky to sort as the result is a DataFrame, and therefore we'd need to rename the column etc.
I have gone ahead and updated the code a little to get rid of the dictionary to Series
conversion though.
In the first exercise, where the goal is to calculate the percentage price change over the year 2013 for an array of tickers, it appears the graph showing the solution is incorrect. The code appears to work, albeit not the most eloquent solution. The "solution" graph appears to show AAPL price change of ~-50% when really Apple appreciated in 2013.
Here is a cleaner implementation of the solution that leverages more of pandas' great functionality.