Tell us what’s happening:
I created a scatter plot based on the year and CSIRO Adjusted sea level being the x and y axis respectively. The next part of the task requires me to use linregress on x and y and created a fitted line onto the scatter plot which I managed. However I need to extrapolate the fitted line to 2050 whereas data was only available from 1880 to 2013. I tried to figure out the CSIRO Adjusted Sea Level of 2050 and append to the dataframe but when trying to plot, the fitted line does not extend to 250 or I am met with this error.
You can plot a line with the slope and intercept from linregress() without appending anything to your data frame. You can also create a linear function to calculate the predicted level for each year.
Please post links to repls for debugging and use code blocks for code/errors so that they are indexable and searchable.
Hi Jeremy, yes I was able to plot using linregress(x, y) where x was the year column from dataframe and y was the sea level column. However I am unsure how to implement the part about creating a linear function to calculate the predicted level for each year. Does that mean I use the linregress slope and intercept to calculate for each year leading up to 2050 and append to dataframe than plot from there or something else?