Module functions.graphy.main_data

Functions

def add_break(df, meta, variable, my_break, weight, select_variable_levels, i, b, very_first_variable)

Add the break to the plot data frame

def add_break_2(df, meta, variable, my_break, my_break_2, weight, select_variable_levels, i, b, m, very_first_variable)

Add the second level break to the plot data frame

def add_label_length(x_break: pandas.core.frame.DataFrame, label_size: int, info: dict) ‑> pandas.core.frame.DataFrame

Calculate the label length for the left labels and the break labels combined

def add_label_wrap(x: pandas.core.frame.DataFrame, length: int) ‑> pandas.core.frame.DataFrame

Wrap the left labels

def add_legend_break_total(x: pandas.core.frame.DataFrame) ‑> pandas.core.frame.DataFrame

Add the total to the legend break in the plot data frame

def add_mean(x: pandas.core.frame.DataFrame, special_variables: list[int]) ‑> pandas.core.frame.DataFrame

Calculate the mean for the plot data frame

def add_percentage(x: pandas.core.frame.DataFrame) ‑> pandas.core.frame.DataFrame
def add_special_column(x: pandas.core.frame.DataFrame, special: list[int], special_column: str, level_column: str, special_last: bool, total_first: bool) ‑> pandas.core.frame.DataFrame

Add a special column to the plot data frame. It helps with ordering the data frame

def add_total(x: pandas.core.frame.DataFrame) ‑> pandas.core.frame.DataFrame

Add the overall total to the plot data frame

def add_total_column(x: pandas.core.frame.DataFrame, multi_base: str = 'Befragte') ‑> pandas.core.frame.DataFrame

Calculate the total column for the plot data frame

def add_variable(df, meta, variable, weight, select_variable_levels, i, very_first_variable)

Add the variable to the plot data frame

def add_variable_copy(x: pandas.core.frame.DataFrame, new_variable: str, old_variable: str)

Add a copy of a variable to the data frame

def create_base_df(df: pandas.core.frame.DataFrame, meta: pyreadstat._readstat_parser.metadata_container, variables: list, breaks: list, breaks_2: list, weight: str, select_variable_levels: list[int], special_variables: list[int]) ‑> pandas.core.frame.DataFrame

Create the base data frame for the plotting

def label_add_count(info: dict, x: pandas.core.frame.DataFrame, show_count: bool, variable: str, count_from_total: bool = False) ‑> pandas.core.frame.DataFrame

Add count to the left labels

Args

info : dict
Information about the presentation
x : pd.DataFrame
Plot data frame
show_count : bool
Decide if count should be shown
variable : str
Variable to count
count_from_total : bool
Count from total or from the break
def label_add_index(info: dict, x: pandas.core.frame.DataFrame, show_index: bool, variable: str, index_from_total: bool = False) ‑> pandas.core.frame.DataFrame

Add index to the left labels (index is the count of the break). This is mainly used for debugging.

def legend_label_add_count(info: dict, x: pandas.core.frame.DataFrame, show_count_legend: bool, variable: str, grouped_once: bool = False, grouped_twice: bool = False) ‑> pandas.core.frame.DataFrame

Add count to the legend labels

Args

info : dict
Information about the presentation
x : pd.DataFrame
Plot data frame
show_count_legend : bool
Decide if count should be shown in elgend
variable : str
Variable to count
grouped_once : bool
variable grouped once
grouped_twice : bool
variable grouped twice

Returns

pd.DataFrame
changed dataframe
def legend_label_add_index(info: dict, x: pandas.core.frame.DataFrame, show_index_legend: bool, variable: str) ‑> pandas.core.frame.DataFrame

Add index to the legend labels (index is the label of the break). This is mainly used for debugging.

Args

info : dict
Information about the presentation
x : pd.DataFrame
Plot data frame
show_count_legend : bool
Decide if count should be shown in legend
variable : str
Variable to count

Returns

pd.DataFrame
changed dataframe
def order_barchart(x: pandas.core.frame.DataFrame, order_by: dict, show_mean: bool, one_option: bool, break_x_axis: bool = False) ‑> pandas.core.frame.DataFrame

Order the plot data frame for a barchart

def order_by_column(x: pandas.core.frame.DataFrame, order_by: str, order_ascending: str) ‑> pandas.core.frame.DataFrame
def order_stacked_barchart(x: pandas.core.frame.DataFrame, order_by: dict, left_by_mean: bool) ‑> pandas.core.frame.DataFrame

Order the plot data frame for a stacked barchart

def remove_label_text(x: pandas.core.frame.DataFrame, remove_text_before_label: str, remove_text_after_label: str, label_text_column: str) ‑> pandas.core.frame.DataFrame

Remove text before or after the label in the labels

def remove_total(x: pandas.core.frame.DataFrame, show_total: bool, variable: str, index_variable: str) ‑> pandas.core.frame.DataFrame
def rename_labels(x: pandas.core.frame.DataFrame, rename_values: dict[str, str], column: str) ‑> pandas.core.frame.DataFrame

Rename the values in the left labels based on the dictionary given in rename_values