Reputation: 81
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'
Upvotes: 6
Views: 22507
Reputation: 165
For me installation via pip was giving errors, therefore I installed it via conda from here.
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")
df = pd.read_html("abc_pandas_profiling.html")
print(df[0])
Upvotes: 0
Reputation: 181
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'
Upvotes: 0
Reputation: 301
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")
Upvotes: 0
Reputation: 105
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
Upvotes: 5
Reputation: 455
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
Upvotes: 1
Reputation: 439
Try in conda environment
!pip install --user pandas-profiling
import pandas_profiling
data.profile_report()
Upvotes: -1
Reputation: 474
This should work for those who want to use the latest version:
pip uninstall pandas_profiling
from anaconda prompt (given you're using Spyder, I'd guess this would be your case) / or command promptpip 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.
Upvotes: 1
Reputation: 2157
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)
Upvotes: 3
Reputation: 81
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.
Upvotes: 0