Tell us what’s happening:
Describe your issue in detail here.
My code passed the test when ran on my local computer. But it raised an import
error when ran on Replit.
Below is the error information:
Traceback (most recent call last): File "main.py", line 2, in <module> import sea_level_predictor File "/home/runner/boilerplate-sea-level-predictor/sea_level_predictor.py", line 1, in <module> import pandas as pd File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.8/site-packages/pandas/__init__.py", line 182, in <module> import pandas.testing File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.8/site-packages/pandas/testing.py", line 7, in <module> from pandas.util.testing import ( File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.8/site-packages/pandas/util/testing.py", line 27, in <module> import pandas._libs.testing as _testing File "pandas/_libs/testing.pyx", line 10, in init pandas._libs.testing File "/home/runner/boilerplate-sea-level-predictor/venv/lib/python3.8/site-packages/numpy/__init__.py", line 284, in __getattr__ raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'bool'
Your code so far
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import linregress
def draw_plot():
Read data from file
df = pd.read_csv(“epa-sea-level.csv”)
result_whole = linregress(df[“Year”], df[“CSIRO Adjusted Sea Level”])
recent = df[df[“Year”] >= 2000]
result_recent = linregress(recent[“Year”],
recent[“CSIRO Adjusted Sea Level”])
years = pd.Series(range(1880, 2051), name=“year”)
Create scatter plot
fig, ax = plt.subplots(figsize=(20, 6))
ax.scatter(df[“Year”],
df[“CSIRO Adjusted Sea Level”],
color=“gray”,
label=“Original”)
Create first line of best fit
ax.plot(years,
years * result_whole.slope + result_whole.intercept,
color=“lightblue”,
label=“Fitted with whole data”)
Create second line of best fit
ax.plot(years[-51:],
years[-51:] * result_recent.slope + result_recent.intercept,
color=“red”,
label=“Fitted with data since 2000”)
Add labels and title
ax.set_xlabel(“Year”)
ax.set_ylabel(“Sea Level (inches)”)
ax.set_title(“Rise in Sea Level”)
plt.legend()
Save plot and return data for testing (DO NOT MODIFY)
plt.savefig(‘sea_level_plot.png’)
return plt.gca()
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0
Challenge: Data Analysis with Python Projects - Sea Level Predictor
Link to the challenge: