REIT project question

Hi
While calculating the daily returns using the CSV containing sbra_adjusted_closings, I am curious why this works:

def rate_of_return(adj_closings): daily_simple_ror = np.diff(adj_closings) / adj_closings[:-1] return daily_simple_ror daily_simple_returns_sbra = rate_of_return(sbra_adj_closings) print(daily_simple_returns_sbra) [codebyte] And this does not: [/codebyte] def rate_of_return(adj_closings): daily_simple_ror = np.diff(adj_closings) / adj_closings return daily_simple_ror daily_simple_returns_sbra = rate_of_return(sbra_adj_closings) print(daily_simple_returns_sbra)

What is the [:-1] doing that allows the former code to work?

1 Like