Loading...

vastorbit.VastFrame.pie

VastFrame.pie(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'], method: str = 'count', of: str | None = None, max_cardinality: None | int | tuple = None, h: None | int | tuple = None, chart: PlottingBase | TableSample | Axes | mFigure | Figure | None = None, categoryorder: Literal['trace', 'category ascending', 'category descending', 'total ascending', 'total descending'] = 'trace', **style_kwargs) PlottingBase | TableSample | Axes | mFigure | Figure

Draws the nested pie chart of the input VastColumns.

Parameters:
  • columns (SQLColumns) – list of the VastColumns names.

  • method (str, optional) –

    The method used to aggregate the data.

    • count:

      Number of elements.

    • density:

      Percentage of the distribution.

    • mean:

      Average of the VastColumns of.

    • min:

      Minimum of the VastColumns of.

    • max:

      Maximum of the VastColumns of.

    • sum:

      Sum of the VastColumns of.

    • q%:

      q Quantile of the VastColumns of (ex: 50% to get the median).

    It can also be a cutomized aggregation, for example: AVG(column1) + 5

  • of (str, optional) – The VastColumns used to compute the aggregation.

  • max_cardinality (int | tuple, optional) – Maximum number of distinct elements for VastColumns 1 and 2 to be used as categorical. For these elements, no h is picked or computed. If of type tuple, represents the ‘max_cardinality’ of each column.

  • h (int | tuple, optional) – Interval width of the bar. If empty, an optimized h will be computed. If of type tuple, it must represent each column’s h.

  • chart (PlottingObject, optional) – The chart object to plot on.

  • **style_kwargs – Any optional parameter to pass to the plotting functions.

Returns:

Plotting Object.

Return type:

obj

Examples

Note

The below example is a very basic one. For other more detailed examples and customization options, please see Pie Chart

Let’s begin by importing vastorbit.

import vastorbit as vo

Let’s also import numpy to create a dataset.

import numpy as np

Let’s generate a dataset using the following data.

data = vo.VastFrame(
    {
        "gender": ['M', 'M', 'M', 'F', 'F', 'F', 'F'],
        "grade": ['A','B','C','A','B','B', 'B'],
    }
)

Below are examples of two types of pie plots:

  • Regular

  • Nested

data.pie(["grade"])
data.pie(columns = ["grade", "gender"])

See also

VastFrame.hist() : Histogram.
VastColumn.bar() : Bar Chart.
VastColumn.pie() : Pie Chart.