graph

Plot Pie Chart

Plot a pie chart based on specified label_column values.

plot_pie_chart(df, label_column, diff_data=[0, 1], diff_labels=['Good', 'Bad'], autopct='%1.1f%%', startangle=90)

Plot a pie chart to visualize the distribution of categorical values in the specified column.

Parameters:
  • df (pandas.DataFrame) – pandas.DataFrame The input DataFrame.

  • label_column (str) – str The name of the column containing categorical values for which the pie chart is created.

  • diff_data (list) – list, optional (default=[0, 1]) The unique values from the label_column for which the pie chart is generated.

  • diff_labels (list) – list, optional (default=[‘Good’, ‘Bad’]) Labels corresponding to the unique values in diff_data.

  • autopct (str) – str, optional (default=’%1.1f%%’) Format for displaying the percentage contribution of each category.

  • startangle (float) – float, optional (default=90) The angle by which the start of the pie chart is rotated.

Returns:

matplotlib.figure.Figure The created matplotlib figure.

Returns:

pandas.Series A Series containing counts of occurrences for each unique value in label_column.

Example:

from df_csv_excel.plot_data import plot_pie_chart

fig, options = plot_pie_chart(df, 'label')