Pandas Profiling / Ydata-profiling

Hi all
I trying to use component streamlit_pandas_profiling,
but get some issues. First of all my code:

import pandas as pd
from ydata_profiling import ProfileReport
import streamlit as st

from streamlit_pandas_profiling import st_profile_report

df = pd.read_csv("https://storage.googleapis.com/tf-datasets/titanic/train.csv")
st.dataframe(df)
pr = ProfileReport(df, title="Report")

st_profile_report(pr)

Please note I use conda and installed ydata_profiling as recommended instead old version pandas_profiling - possible its rise error…

However I get this

AttributeError: module 'matplotlib.cbook' has no attribute 'mplDeprecation'
Traceback:
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
File "/Users/tgottfried/Documents/Git/cvat-dashboard/pages/8_EDA_for_Data.py", line 14, in <module>
    st_profile_report(pr)
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/streamlit_pandas_profiling/__init__.py", line 54, in st_profile_report
    _render_component(html=report.to_html(), height=height, key=key, default=None)
                           ^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/profile_report.py", line 470, in to_html
    return self.html
           ^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/profile_report.py", line 277, in html
    self._html = self._render_html()
                 ^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/profile_report.py", line 385, in _render_html
    report = self.report
             ^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/profile_report.py", line 271, in report
    self._report = get_report_structure(self.config, self.description_set)
                                                     ^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/profile_report.py", line 253, in description_set
    self._description_set = describe_df(
                            ^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/model/describe.py", line 130, in describe
    scatter_matrix[x][y] = progress(
                           ^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/utils/progress_bar.py", line 11, in inner
    ret = fn(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/model/pairwise.py", line 31, in get_scatter_plot
    return scatter_pairwise(config, df_temp[x], df_temp[y], x, y)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/anaconda3/envs/stapp/lib/python3.11/contextlib.py", line 80, in inner
    with self._recreate_cm():
File "/opt/anaconda3/envs/stapp/lib/python3.11/contextlib.py", line 144, in __exit__
    next(self.gen)
File "/opt/anaconda3/envs/stapp/lib/python3.11/site-packages/ydata_profiling/visualisation/context.py", line 85, in manage_matplotlib_context
    warnings.filterwarnings("ignore", category=matplotlib.cbook.mplDeprecation)
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I google problem, and solution here does not help for me. My version of matplotlib 3.8.0

Hi,
Try to downgrade your matplotlib library. It worked in my case. Check this solution (python - Matplotlib AttributeError: module 'matplotlib.cbook' has no attribute '_define_aliases' - Stack Overflow). It worked in my case.

Would post this in AttributeError: module 'matplotlib.cbook' has no attribute 'mplDeprecation' but since that is locked I’m posting it here.

If you are okay with the slightly annoying UX of using an iFrame you don’t really need the streamlit-pandas-profiling or streamlit-ydata-profiling dependancies. Just do this:

from ydata_profiling import ProfileReport

profile = ProfileReport(df, title="Pandas Profiling Report", explorative=True)

# Generate the report HTML
report_html = profile.to_html()

st.subheader("Pandas Profiling Report")
# Adjust the width and height to best fit your screen
st.components.v1.html(report_html, width=1000, height=550, scrolling=True)