5

I wanted to use pandas-profiling to do some eda on a dataset but I'm getting an error : AttributeError: 'DataFrame' object has no attribute 'profile_report'

I have created a python script on spyder with the following code :

import pandas as pd import pandas_profiling data_abc = pd.read_csv('abc.csv') profile = data_abc.profile_report(title='Pandas Profiling Report') profile.to_file(output_file="abc_pandas_profiling.html")

AttributeError: 'DataFrame' object has no attribute 'profile_report'

Adhish
  • 61
  • 1
  • 1
  • 7
  • Same issue here, saw a ticket that was closed but only identifies there is a problem https://github.com/pandas-profiling/pandas-profiling/issues/201 – Geochem B Aug 06 '19 at 16:24

9 Answers9

5

The df.profile_report() entry point is available from v2.0.0. soln from here

Did you install pandas-profiling via pip or conda?

use : pip install -U pandas-profiling to solve this and restart your kernel

RobinKiplangat
  • 95
  • 1
  • 10
3

The issue is that the team hasn't updated the pip or conda installations yet (described here). If you installed using one of these, try this for the time being.

profile = pandas_profiling.ProfileReport(df)
print(profile)
kevin_theinfinityfund
  • 1,631
  • 17
  • 18
1

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

  1. Run pip uninstall pandas_profiling from anaconda prompt (given you're using Spyder, I'd guess this would be your case) / or 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.

Ray's Web Presence
  • 464
  • 1
  • 5
  • 15
  • 1
    I just used this command to uninstal the package that I installed with Anaconda3, and launched pip install pandas_profiling: I got the last release 2.8.0 and is running - Thx – CRAZYDATA Sep 02 '20 at 15:38
1

For the those using google colabs, the profiling library is outdated, hence use the command below and restart the runtime

! pip install https://github.com/pandas-profiling/pandas-profiling/archive/master.zip 
KevinCK
  • 415
  • 3
  • 10
0

The only workaround I found was that the python script I made is getting executed from the command prompt and giving the correct output but the code is still giving an error in Spyder.

Adhish
  • 61
  • 1
  • 1
  • 7
0

Some of the version of the pandas-profiling does not work for me and I installed 2.8.0 version and it work for me.

!pip install pandas-profiling==2.8.0
import numpy as np
import pandas as pd
import pandas_profiling as pp
df = pd.read_csv('/content/sample_data/california_housing_train.csv')
profile = df.profile_report(title = "Data Profiling Report")
profile.to_file("ProfileReportTest.html")
Suman Shrestha
  • 161
  • 1
  • 6
0

If none of the above worked, can you check by setting the encoding to unicode_escape in read_csv? It may be due to one of your columns

 encoding = 'unicode_escape'
WarlockQ
  • 141
  • 2
  • 10
0

My solution

For me installation via pip was giving errors, therefore I installed it via conda from here.

Code Example

And here is the code example to use profile report:

import pandas as pd
from pandas_profiling import ProfileReport

data_abc = pd.read_csv('abc.csv')
profile = ProfileReport(data_abc, minimal=True)
profile.to_file("abc_pandas_profiling.html")

To read the html file I used the following code

df = pd.read_html("abc_pandas_profiling.html")
print(df[0])
-1

Try in conda environment

!pip install --user pandas-profiling
import pandas_profiling
data.profile_report()
Biman Pal
  • 391
  • 4
  • 9