1

Please help, I get the error below running jupyter notebook.

import numpy as np
import pandas as pd
from helper import boston_dataframe

np.set_printoptions(precision=3, suppress=True)

Error:

ImportError                               Traceback (most recent call last)
<ipython-input-3-a6117bd64450> in <module>
      1 import numpy as np
      2 import pandas as pd
----> 3 from helper import boston_dataframe
      4 
      5 

ImportError: cannot import name 'boston_dataframe' from 'helper' (/Users/irina/opt/anaconda3/lib/python3.8/site-packages/helper/__init__.py)
Red
  • 26,798
  • 7
  • 36
  • 58
Irina
  • 13
  • 3
  • 1
    I suspect that you installed `helper` which is this code: https://github.com/gmr/helper available from pypi under the `helper` project. It does not contain a `boston_dataframe` variable. So the question here is which `helper` are you suppose to use for this notebook? Is there a `helper` code somewhere distributed with this notebook? – astrochun Feb 20 '21 at 13:39
  • there is a helper file that came with the notebook. i have downloaded it. It works for other notebooks but not fr this one – Irina Feb 20 '21 at 13:46
  • 1
    This seems like a relative path. See the below answer. If you want to use it more generally then you will want to include it in a number of ways, such as adding the directory to PYTHONPATH. But having this specific code in the same place will be clear which `helper` library/module you're using. – astrochun Feb 20 '21 at 13:57

1 Answers1

2

Since you are not giving the where you get the notebook, I have to guess that you get it from this course Supervised Learning: Regression provided IBM.

In the zip folder in week 1, it provides helper.py.

labwork

What you need to do it is to change the directory to where this file is. Change IPython/Jupyter notebook working directory

Alternatively, you can load boston data from sklearn then load it to Pandas Dataframe

Advices for you:

dinhanhx
  • 198
  • 2
  • 13