6

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'

1

9 Answers 9

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

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

Comments

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)

Comments

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.

1 Comment

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
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 

Comments

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.

Comments

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")

Comments

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'

Comments

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])

Comments

-1

Try in conda environment

!pip install --user pandas-profiling
import pandas_profiling
data.profile_report()

Comments

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.