Data Analysis with Python Projects - Sea Level Predictor

Tell us what’s happening:
Unable to run tests on my code keeps giving the error

/home/runner/sea-level-predictor/venv/lib/python3.8/site-packages/pandas/util/testing.py:27: FutureWarning: In the future np.bool will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions.
import pandas._libs.testing as _testing
Traceback (most recent call last):
File “main.py”, line 2, in
import sea_level_predictor
File “/home/runner/sea-level-predictor/sea_level_predictor.py”, line 1, in
import pandas as pd
File “/home/runner/sea-level-predictor/venv/lib/python3.8/site-packages/pandas/init.py”, line 182, in
import pandas.testing
File “/home/runner/sea-level-predictor/venv/lib/python3.8/site-packages/pandas/testing.py”, line 7, in
from pandas.util.testing import (
File “/home/runner/sea-level-predictor/venv/lib/python3.8/site-packages/pandas/util/testing.py”, line 27, in
import pandas._libs.testing as _testing
File “pandas/_libs/testing.pyx”, line 10, in init pandas._libs.testing
File “/home/runner/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’

Not sure how to proceed, couldn’t find anyone with the exact same issue

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')
  # Create scatter plot
  plt.scatter(x=df.Year,y=df['CSIRO Adjusted Sea Level'])

  # Create first line of best fit
  line = linregress(x=df.Year, y=df['CSIRO Adjusted Sea Level'])

  # Create second line of best fit
  line2 = linregress(x=df[df['Year'] >= 2000].Year, y=df[df['Year'] >= 2000]['CSIRO Adjusted Sea Level'])

  # Add labels and title
  plt.plot(df.Year,line.intercept + line.slope*df.Year)
  plt.plot(df[df['Year'] >= 2000].Year,line2.intercept + line2.slope*df[df['Year'] >= 2000].Year)
  plt.xlabel('Year')
  plt.ylabel('Sea Level (inches)')
  plt.title('Rise in Sea Level')
  
  # Save plot and return data for testing (DO NOT MODIFY)
  plt.savefig('sea_level_plot.png')
  return plt.gca()

Link to my replit: sea-level-predictor - Replit
Your browser information:

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

Challenge: Data Analysis with Python Projects - Sea Level Predictor

Link to the challenge:

I had the same problem.
To get past it, I opened a shell in replit and gave this command “python -m poetry update”
It looked in the poetry file and updated the dependencies.
I have not finished the project yet, but I am not get that error anymore.

2 Likes

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