I am getting the right image but still does not pass the tests

I have done sea_level_predictor in jupyter and I get the similar image to the example. Yet the test fails. I do not know where I am stuck.

def draw_plot():
       df = pd.read_csv("epa-sea-level.csv",
                index_col=[0])


    # Create scatter plot
  plt.scatter(df.index, df['CSIRO Adjusted Sea Level'])

    # Create first line of best fit
  slope, intercept, rvalue, pvalue, stderr=linregress(df.index,df['CSIRO Adjusted Sea Level'])
  slope, intercept, rvalue, pvalue, stderr=linregress(df.index,df['CSIRO Adjusted Sea Level'])
  x=np.linspace(1880,2050, 2050-1880)
  y= (slope*x)+intercept
  plt.plot(x,y)

    # Create second line of best fit
  df_2000=df.copy()
  mask=df_2000[df.index <=2000]
  df_2000=df_2000.drop(mask.index)

  slope1, intercept1, rvalue1, pvalue1, stderr1=linregress(df_2000.index,df_2000['CSIRO Adjusted Sea Level'])
  x1=np.linspace(2000,2050, 2050-2000)
  y1= (slope1*x1)+intercept1
  plt.plot(x1,y1, color='green')

    # Add labels and title
  plt.xlabel("Year")
  plt.ylabel("Sea Level (inches)")
  plt.title("Rise in Sea Level")

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36

Challenge: Sea Level Predictor

Link to the challenge:

Also I checked the values from test module. And it is same as well. It fails in test_plot_lines where those values are ploted

Please post a link to your replit so we can run the code and see the result.

boilerplate-sea-level-predictor - Replithttps://replit.com/@SAFASHAHABUDDIN/boilerplate-sea-level-predictor#sea_level_predictor.py

This is the link. Thank you.

https://replit.com/@SAFASHAHABUDDIN/boilerplate-sea-level-predictor#sea_level_predictor.py

Hi I haven’t got any reply, so I was wondering what to do?

Ah sorry, I didn’t find anything really wrong… Also it’s not helpful that I don’t know how to see the console after the project is run…
I remember having some trouble as to if the year 2000 was inclusive or exclusive for the second regression. Maybe try that?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.