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: