1

Experts,

Here is my block of code and I am getting the below error.

import pandas 
import os
trainFile = r'C:\PythonProjects\sample.csv'
pwd = os.getcwd()
os.chdir(os.path.dirname(trainFile))
trainData = pandas.read_csv(os.path.basename(trainFile))
p=pandas_profiling.ProfileReport(trainData)
os.chdir(pwd)

--------------------------------------------------------------------------- NameError Traceback (most recent call last) in () 6 trainData = pandas.read_csv(os.path.basename(trainFile)) ----> 7 p=pandas_profiling.ProfileReport(trainData) 8 os.chdir(pwd)

Can you provide your inputs/suggestions to resolve this error pls. NameError: name 'pandas_profiling' is not defined

3 Answers 3

3

Remember to run import pandas_profiling before using it.

This should work for those who want to use the latest version:

  1. Run pip uninstall pandas_profiling or conda uninstall pandas_profiling from anaconda prompt/command prompt
  2. Run pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip

If you're using something like a Jupyter Notebook/Jupyter Lab, be sure to restart your kernel and re-import your packages.

I hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

0

Try to run pip install pandas-profiling command in a separate cell in the jupyter notebook just before importing all the packages.

After this re-start your kernel and re-run the whole notebook again. This should give you the required profile report.

Comments

-1

"pandas_profiling" comes as a pip packages. Have you installed the package..?

pip install pandas-profiling

or maybe you have installed the package in some virtual environment, not in your complete path.

See the link pandas-profiling

2 Comments

Yes I did check the installation using pip freeze command the package was installed successfully and I do not have a virtual environment. Is there a way I could provide the absolute path of this package in my program.
Yes. Pycharm removed the reference citing it could not able to locate the reference.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.