py_outliers_utils.visualize_outliers

Module Contents

Functions

visualize_outliers(dataframe, columns=None, type='violin')

A function that plot the distribution of the given data.

py_outliers_utils.visualize_outliers.visualize_outliers(dataframe, columns=None, type='violin')[source]

A function that plot the distribution of the given data.

Parameters
  • dataframe (pandas.core.frame.DataFrame) – The target dataframe where the function is performed.

  • columns (list, default=None) – The target columns where the function needed to be performed. Default is None, the function will check all columns.

  • type (string, default='violin') – The method of plotting the distribution. - if “violin” : Return a violin plot with boxplot layer - if “boxplot” : Return a boxplot

Returns

an altair plot with data distribution.

Return type

altair.vegalite.v4.api.Chart

Examples

>>> import pandas as pd
>>> import altair as alt
>>> df = pd.DataFrame({
>>>    'SepalLengthCm' : [0.1, 4.9, 52.7, 5.5, 5.1, 50, 5.4, 179.0, 5.2, 5.3, 5.1],
>>>    'SepalWidthCm' : [1.4, 1.4, 20, 2.0, 0.7, 1.6, 1.2, 14, 1.8, 1.5, 2.1],
>>>    'PetalWidthCm' : [0.2, 0.2, 0.2, 0.3, 0.4, 0.5, 0.5, 0.6, 0.4, 0.2, 5]
>>> })
>>> visualize_outliers(df, columns=['SepalLengthCm', 'SepalWidthCm'])