Ask Question

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.

+4
Answers (1)
  1. 9 September, 13:59
    0
    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)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “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 ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers