pydit.statistics.benford.benford_to_plot

pydit.statistics.benford.benford_to_plot(df, column_name, first_n_digits=1, filename=None, show=True)[source]

Plots the histogram with Benford’s Law expected and the actual frequencies.

Parameters:
  • obj (DataFrame or Series or list) – The data to be analyzed.

  • column_name (str, optional, default: "") – The column name to be analyzed. Not needed for series or lists

  • first_n_digits (int, optional, default: 1) – The number of first digits to be considered.

  • filename (str, optional, default: None) – The filename to save the plot. If None, the plot is not saved. example: “./output/benford_plot.png” or “./output/benford_plot.pdf”

  • show (bool, optional, default: True) – If True, the plot is shown.

Returns:

A new dataframe with the expected and actual Benford’s Law frequency. Also it would return a plot of the histogram with the expected and actual frequencies.

Return type:

DataFrame