# This is how to use Sweetviz with Streamlit

**URL:** <https://discuss.streamlit.io/t/this-is-how-to-use-sweetviz-with-streamlit/10897>\
**Category:** Show the Community!\
**Created:** [March 18, 2021, 1:20am UTC](https://discuss.streamlit.io/t/this-is-how-to-use-sweetviz-with-streamlit/10897 "2021-03-18T01:20:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![asehmi](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/asehmi/32/1771_2.png) [@asehmi](https://discuss.streamlit.io/u/asehmi)\
**Post date:** [March 18, 2021, 1:20am UTC](https://discuss.streamlit.io/t/this-is-how-to-use-sweetviz-with-streamlit/10897/1 "2021-03-18T01:20:04Z")

</div>

If you’ve created a Streamlit component with React you’ll have a `frontend/public` folder from which to serve static HTML files. I figured if I could generate the static analysis output of [`Sweetviz`](https://github.com/fbdesignpro/sweetviz) into that folder, then it would be easy to display it in my `Streamlit` app. Sure enough, it is very easy:

```python
import streamlit as st
import streamlit.components.v1 as components
import pandas as pd
# https://pypi.org/project/sweetviz/
# https://github.com/fbdesignpro/sweetviz
import sweetviz as sv

def app(title=None):

    st.title(title)
    df = pd.read_csv('./data/Time_Series.csv')
    st.write(df.head())

    skip_columns_years = [str(y) for y in range(2016, 2026)]
    skip_columns_time_series = ['Date of last update', 'Databank code', 'Scenario', 'Location code', 'Indicator code'] + skip_columns_years

    # Use the analysis function from sweetviz module to create a 'DataframeReport' object.
    analysis = sv.analyze([df,'EDA'], feat_cfg=sv.FeatureConfig(
        skip=skip_columns_time_series,
        force_text=[]), target_feat=None)

    # Render the output on a web page.
    analysis.show_html(filepath='./frontend/public/EDA.html', open_browser=False, layout='vertical', scale=1.0)
    components.iframe(src='http://localhost:3001/EDA.html', width=1100, height=1200, scrolling=True)

app(title='Sweet Visualization')

```

I’m loading a CSV of time series data (with annual data for 2016-2025). The year/value columns and a few others are ignored in the EDA analysis (`skip_columns_years`, `skip_columns_time_series`). `Sweetviz` generates its analysis output HTML file into `'./frontend/public/EDA.html'` (i.e., the component’s static content folder). `analysis.show_html()` is configured to not open the analysis itself in a separate browser window. Finally, I display the static HTML file with `components.iframe()`!

There are just two lines of important `Sweetviz` code and in combination with `Streamlit` you can achieve something pretty powerful for your EDA tasks.

P.S. From the docs: _[Pandas-Profiling](https://github.com/pandas-profiling/pandas-profiling) was the original inspiration for this project._

 ![streamlit_sweetviz](https://global.discourse-cdn.com/streamlit/original/2X/9/9a593ac6d1ef6fcaf306c5b24787ca9c153b6c7f.gif)

---

<div class="post-metadata">

**Author:** ![randyzwitch](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/randyzwitch/32/58772_2.png) [@randyzwitch](https://discuss.streamlit.io/u/randyzwitch)\
**Post date:** [May 13, 2022, 8:56pm UTC](https://discuss.streamlit.io/t/this-is-how-to-use-sweetviz-with-streamlit/10897/2 "2022-05-13T20:56:29Z")

</div>


