Skip to content

Latest commit

 

History

History
116 lines (60 loc) · 2.84 KB

plot_bivariate_categorical_categorical_summary.rst

File metadata and controls

116 lines (60 loc) · 2.84 KB
.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        Click :ref:`here <sphx_glr_download_auto_examples_bivariate_summaries_plot_bivariate_categorical_categorical_summary.py>`
        to download the full example code

.. rst-class:: sphx-glr-example-title

Bivariate Categorical-Categorical Summary

Example of bivariate eda summary for a pair of categorical variables

The summary computes the following:

  • Categorical heatmap with counts and percentages for each level combo
  • Barplot showing distribution of column2's levels within each level of column1
  • Lineplot showing distribution of column2's levels across each level of column1
import pandas as pd
import plotly

import intedact

Here we look at how diamond cut quality and clarity quality are related.

data = pd.read_csv(
    "https://raw.githubusercontent.com/mwaskom/seaborn-data/master/diamonds.csv"
)
data["cut"] = pd.Categorical(
    data["cut"],
    categories=["Fair", "Good", "Very Good", "Premium", "Ideal"],
    ordered=True,
)
data["clarity"] = pd.Categorical(
    data["clarity"],
    categories=["I1", "SI2", "SI1", "VS2", "VS1", "VVS2", "VVS1", "IF"],
    ordered=True,
)
fig = intedact.categorical_categorical_summary(
    data, "clarity", "cut", barmode="group", fig_width=700
)
plotly.io.show(fig)
.. rst-class:: sphx-glr-timing

   **Total running time of the script:** ( 0 minutes  0.585 seconds)


.. only :: html

 .. container:: sphx-glr-footer
    :class: sphx-glr-footer-example



  .. container:: sphx-glr-download sphx-glr-download-python

     :download:`Download Python source code: plot_bivariate_categorical_categorical_summary.py <plot_bivariate_categorical_categorical_summary.py>`



  .. container:: sphx-glr-download sphx-glr-download-jupyter

     :download:`Download Jupyter notebook: plot_bivariate_categorical_categorical_summary.ipynb <plot_bivariate_categorical_categorical_summary.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_