Change Calculator¶
-
class
components.change_calculator.ChangeCalculator¶ The ChangeCalculator object contains functions used for Change Calculator and Change Calculator 2 tab
Methods
compute_change(df, x_col, x_max, y_col, y_max)Compute change between two periods
compute_changes(df, col_identifier, …)Compute change between multiple periods
convert_to_float(df, col, col_max)Convert values to float for column(s) in DataFrame, normalize column if necessary
get_box_plot(df, cols)Get figure for plot
get_line_plot(app, df2)Get figure for plot
get_parallel_coord(df, col_identifier, …)Get figure for plot
get_scatter_plot(df, x_col, y_col)Get figure for plot
remove_null(df, col)Remove null values from column(s) in DataFrame
remove_string_values(df, col)Remove non-integer values from column(s) in DataFrame
transpose_dataframe(df, col_identifier, cols)Convert long DataFrame to wide DataFrame
-
compute_change(df, x_col, x_max, y_col, y_max)¶ Compute change between two periods
Performs removing non-integer values, removing null rows and conversion of values to float, then adds in ‘Change’ column as difference between y_col and x_col
- Parameters
df (pd.DataFrame) – input DataFrame
x_col (str) – column for x-axis
x_max (int) – maximum value for x-axis, could be None or empty string
y_col (str) – column for x-axis
y_max (int) – maximum value for y-axis, could be None or empty string
- Returns
(pd.DataFrame)
-
compute_changes(df, col_identifier, list_of_tuples)¶ Compute change between multiple periods
Performs removing non-integer values, removing null rows and conversion of values to float
- Parameters
df (pd.DataFrame) – input DataFrame
col_identifier (str) – column for index
list_of_tuples (list) – data from table that contains tuple of column(s) and their maximum value(s)
- Returns
(pd.DataFrame)
-
static
convert_to_float(df, col, col_max)¶ Convert values to float for column(s) in DataFrame, normalize column if necessary
- Parameters
df (pd.DataFrame) – input DataFrame
col (str) – column to convert values to float
col_max (int) – maximum value for column, could be None or empty string
- Returns
(pd.DataFrame)
-
static
get_box_plot(df, cols)¶ Get figure for plot
Adds plotly.graph_objects charts for box plot, visualizing summary statistics
- Parameters
df (pd.DataFrame) – input DataFrame
cols (list) – list of column(s) for results summary
- Returns
graphical result of change calculator 2
- Return type
(dict)
-
static
get_line_plot(app, df2)¶ Get figure for plot
Adds plotly.graph_objects charts for line plot
- Parameters
df2 (pd.DataFrame) – input DataFrame
- Returns
2-element tuple
(list): instructions for interacting with figure
(dict): graphical result of change calculator 2
-
static
get_parallel_coord(df, col_identifier, list_of_tuples)¶ Get figure for plot
Adds plotly.graph_objects charts for parallel coordinate plot
- Parameters
df (pd.DataFrame) – input DataFrame
col_identifier (str) – column for index
list_of_tuples (list) – data from table that contains tuple of column(s) and their maximum value(s)
- Returns
2-element tuple
(list): instructions for interacting with figure
(dict): graphical result of change calculator 2
-
static
get_scatter_plot(df, x_col, y_col)¶ Get figure for plot
Adds plotly.graph_objects charts for violin plot, line plot and marginal histograms
- Parameters
df (pd.DataFrame) – input DataFrame
x_col (str) – column for x-axis
y_col (str) – column for x-axis
- Returns
(dict)
-
static
remove_null(df, col)¶ Remove null values from column(s) in DataFrame
- Parameters
df (pd.DataFrame) – input DataFrame
col (str/list) – column(s) to remove null values from
- Returns
(pd.DataFrame)
-
static
remove_string_values(df, col)¶ Remove non-integer values from column(s) in DataFrame
- Parameters
df (pd.DataFrame) – input DataFrame
col (str/list) – column(s) to remove non-integer values from
- Returns
(pd.DataFrame)
-
static
transpose_dataframe(df, col_identifier, cols)¶ Convert long DataFrame to wide DataFrame
- Parameters
df (pd.DataFrame) – input DataFrame
col_identifier (str) – column for index, which will be the new DataFrame column names
cols (list) – column names, which will be the new DataFrame index
- Returns
(pd.DataFrame)
-