Very often in data science, we are interested in understanding how values change with time. Use np.diff and np.max (or just max) to calculate the largest annual change in population between any two consecutive years.

Respuesta :

Answer:

Explanation:

import numpy as np

#we define the function that takes year1 and year2 array values and return the maximum of the difference.

def max_diff(year1, year2):

#we pass the difference along the array into diff

diff = np.diff(year1, year2)

#then we take the max value

max = np.argmax(diff)

return max

#the function can be called by initializing

max_val = max_diff(year1_array, year2_array)