Pandas Profiling - NameError: name 'pandas_profiling' is not defined

user3512380 picture user3512380 · Jun 8, 2017 · Viewed 9.3k times · Source

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

Answer

Ray's Web Presence picture Ray's Web Presence · Nov 13, 2019

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.