Hello everyone,
I have been trying to upload my code but when I run it the message is the following:
‘module numpy has no attribute bool’.
This is my code:
def draw_plot():
# Read data from file
df = pd.read_csv('epa-sea-level.csv')
# Create scatter plot
fig,ax=plt.subplots()
ax.scatter(data=df, x='Year', y='CSIRO Adjusted Sea Level')
# Create first line of best fit
x = df.Year
y=df['CSIRO Adjusted Sea Level']
slope, intercept, r, p, se = linregress(x, y)
years_to_2050 = pd.Series(range(1880,2051))
ax.plot(years_to_2050, intercept+slope*years_to_2050, 'g')
# Create second line of best fit
new_df = df[df.Year>=2000]
new_x = new_df.Year
new_y = new_df['CSIRO Adjusted Sea Level']
new_slope, new_intercept, new_r, new_p, new_se = linregress(new_x, new_y)
new_to_2050 = years_to_2050[years_to_2050>=2000]
ax.plot(new_to_2050, new_intercept+new_slope*new_to_2050, 'y')
# Add labels and title
ax.set_title('Rise in Sea Level')
ax.set_ylabel('Sea Level (inches)')
ax.set_xlabel('Year')
# Save plot and return data for testing (DO NOT MODIFY)
#plt.savefig('sea_level_plot.png')
return plt.gca()
What should I do? When I run it on my Jupyter Notebook it works fine.
Many thanks in advance.