Sea level predictor: test_plot_lines

FAIL: test_plot_lines (test_module.LinePlotTestCase)

Traceback (most recent call last):
File “/home/runner/boilerplate-sea-level-predictor-1/”, line 34, in test_plot_lines
self.assertEqual(actual, expected, “Expected different line for first line of best fit.”)
AssertionError: Lists differ: [0.0, 0.220472441, -0.440944881, -0.232283[1677 chars]4951] != [-0.5421240249263661, -0.4790794409142336,[3256 chars]2443]

First differing element 0:

Second list contains 36 additional elements.
First extra element 134:

Diff is 5939 characters long. Set self.maxDiff to None to see it. : Expected different line for first line of best fit.

what is the reason behind it?

The error message states that your first line of best fit is wrong.
Your numbers indicate it’s not even a straight line.

So you gotta work on that.
Also pretty sure you are supposed to save the plot, looking at that might help understand the error.

Finally, please provide a link to your code if you want further help.
This way people can actually tell you where the error comes from.

thnks for the response
here’s the code:
def draw_plot():
# Read data from file
df = pd.read_csv(“epa-sea-level.csv”)
# Create scatter plot
plt.scatter(df.Year, df[“CSIRO Adjusted Sea Level”])
plt.ylabel(‘CSIRO Adjusted Sea Level’)

# Create first line of best fit
year1 = list(range(1880, 2050)) 
year1 = pd.Series(year1)
year2 = list(range(2000, 2050)) 
year2 = pd.Series(year2)

res = linregress(df.Year, df["CSIRO Adjusted Sea Level"])
df2 = df[df.Year>= 2000]
res2 = linregress(df2.Year, df2["CSIRO Adjusted Sea Level"])

plt.plot(df.Year, df["CSIRO Adjusted Sea Level"], 'o', markersize = 5.2, label='original data')
plt.plot(year1, res.intercept + res.slope*year1, 'r', linewidth=2.5, label='fitted line 1')

# Create second line of best fit
plt.plot(year2, res2.intercept + res2.slope*year2, 'r', linewidth=2.5, label='fitted line 2', color='green')

# Add labels and title
plt.ylabel('Sea Level (inches)')
plt.title('Rise in Sea Level')

# Save plot and return data for testing (DO NOT MODIFY)
return plt.gca()