Hi,
I am trying to resolve the last error, but I am not able to locate the issue.
I think it is the way I set up the x-values, but can’t pinpoint what the issue is.
here is the error message I get:
======================================================================
FAIL: test_plot_lines (test_module.LinePlotTestCase)Traceback (most recent call last):
File “/home/runner/boilerplate-sea-level-predictor/test_module.py”, line 34, in test_plot_lines
self.assertEqual(actual, expected, “Expected different line for first line of best fit.”)
AssertionError: Lists differ: [-0.5421240249263519, -0.4179452988418433, -0.293766572757[1880 chars]9947] != [-0.5421240249263661, -0.4790794409142336, -0.416034856902[3240 chars]2443]First differing element 0:
-0.5421240249263519
-0.5421240249263661Second list contains 70 additional elements.
First extra element 100:
5.762334376287114Diff is 6123 characters long. Set self.maxDiff to None to see it. : Expected different line for first line of best fit.
Ran 4 tests in 9.435s
FAILED (failures=1)
and here is the code:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import linregress
import seaborn as snsdef draw_plot():
# Read data from file
df = pd.read_csv(‘epa-sea-level.csv’)# Create scatter plot fig, ax = plt.subplots(figsize=(16, 9)) x = plt.scatter(data=df, x='Year', y='CSIRO Adjusted Sea Level') # Create first line of best fit lin_func = linregress(df['Year'], df['CSIRO Adjusted Sea Level']) x_fit = np.linspace(np.min(df['Year']), np.max(2050)) y_fit = x_fit * lin_func[0] + lin_func[1] ax = sns.regplot(data=df, x=x_fit, y=y_fit) xlim = [1850,2075] ax.set_xlim(xlim) # Create second line of best fit df_after2000 = df.iloc[120:] lin_func2 = linregress(df_after2000['Year'], df_after2000['CSIRO Adjusted Sea Level']) x_fit2 = np.linspace(np.min(2000), np.max(2050)) y_fit2 = lin_func2[0] * x_fit2 + lin_func2[1] ax = sns.regplot(data=df, x=x_fit2, y=y_fit2) # Add labels and title ax.set_xlabel('Year') ax.set_ylabel('Sea Level (inches)') ax.set_title('Rise in Sea Level') # Save plot and return data for testing (DO NOT MODIFY) plt.savefig('sea_level_plot.png') return plt.gca()
and here is the link to my code:
any help would be great!
Thanks you very much