I wrote the function to calculate the values of the linear regression based on scipy.stats.linregress. But when I apply it to my dataset, the code runs for a long time, abou