Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Get our data for SPY going back to 2003 and check out the last 5 rows
- df = get_pricing('spy', start_date = '2003-01-01', end_date = '2019-09-15', frequency = 'daily')
- df.tail()
- #Make a new column containing daily percent changes
- df['1_day_percent_change'] = df['price'].pct_change()
- df.tail()
- #Grab our new "1_day_percent_change" column and grab the
- #5 largest daily percentage increases
- df['1_day_percent_change'].nlargest(5)
- #Grab our new "1_day_percent_change" column and grab the
- #5 smallest daily percentage increases
- df['1_day_percent_change'].nsmallest(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement