.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "checks_gallery/tabular/data_integrity/plot_is_single_value.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_checks_gallery_tabular_data_integrity_plot_is_single_value.py: .. _plot_tabular_is_single_value: Is Single Value *************** This notebook provides an overview for using and understanding the Is Single Value check. **Structure:** * `What is the Is Single Value check <#what-is-feature-label-correlation>`__ * `Load Data <#load-data>`__ * `Run the check <#run-the-check>`__ .. GENERATED FROM PYTHON SOURCE LINES 18-22 What is the Is Single Value check ==================================== The ``IsSingleValue`` check checks if there are columns which have only a single unique value in all rows. .. GENERATED FROM PYTHON SOURCE LINES 25-27 Imports ======= .. GENERATED FROM PYTHON SOURCE LINES 27-34 .. code-block:: default import numpy as np import pandas as pd from sklearn.datasets import load_iris from deepchecks.tabular.checks import IsSingleValue .. GENERATED FROM PYTHON SOURCE LINES 35-37 Load Data ========= .. GENERATED FROM PYTHON SOURCE LINES 37-41 .. code-block:: default iris = load_iris() X = iris.data .. GENERATED FROM PYTHON SOURCE LINES 42-44 Run the check ================= .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: default IsSingleValue().run(pd.DataFrame(X)) .. raw:: html
Single Value in Column


.. GENERATED FROM PYTHON SOURCE LINES 49-50 If ``None`` is given as a value, it will be ignored (this can be changed with ``ignore_nan`` set to ``False``): .. GENERATED FROM PYTHON SOURCE LINES 50-55 .. code-block:: default df = pd.DataFrame({'a': [3, 4, 1], 'b': [2, 2, 2], 'c': [None, None, None], 'd': ['a', 4, 6]}) sv = IsSingleValue() sv.run(df) .. raw:: html
Single Value in Column


.. GENERATED FROM PYTHON SOURCE LINES 56-65 .. code-block:: default # Ignoring NaN values: IsSingleValue(ignore_nan=True).run(pd.DataFrame({ 'a': [3, np.nan], 'b': [2, 2], 'c': [None, np.nan], 'd': ['a', 4] })) .. raw:: html
Single Value in Column


.. GENERATED FROM PYTHON SOURCE LINES 66-67 Ignoring specific columns by name is also possible: .. GENERATED FROM PYTHON SOURCE LINES 67-69 .. code-block:: default sv_ignore = IsSingleValue(ignore_columns=['b', 'c']) sv_ignore.run(df) .. raw:: html
Single Value in Column


.. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.176 seconds) .. _sphx_glr_download_checks_gallery_tabular_data_integrity_plot_is_single_value.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_is_single_value.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_is_single_value.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_