generate_bin_measures

generate_bin_measures

Functions

Name Description
add_bin_measures An internally called function that creates a TMDL file from a pandas dataframe

add_bin_measures

generate_bin_measures.add_bin_measures(
    dashboard_path,
    dataset_name,
    color_var,
    percentile_bin_breaks,
    color_palette,
    filtering_var,
    location_var,
    data_filtering_condition=None,
)

An internally called function that creates a TMDL file from a pandas dataframe

:param str dashboard_path: The path where the dashboard files are stored. (This is the top level directory containing the .pbip file and Report and SemanticModel folders). :param str dataset_name: The name of the dataset. This should be the basename of the original file without the extension. For example if you loaded “%userprofile%/documents/datasets/birds.csv”, the dataset name would be “birds”. :param str dataset_id: The dataset’s UUID, this will be generated by the outer level function that calls create_tmdl(). :param DataFrame dataset: This is a pandas dataframe of the csv’s content. The pd.read_csv() function is called by the outer level function that calls create_tmdl(). :param dict data_filtering_condition: This is a key value pair for filtering long data. The key should be the column you want to look for and the value should be the value in that column that you want to filter for.For example if the original data has a column called metric with a variety of different metrics and you want to filter the dataset for only rows where the column is equal to “adj_rate”, you should provide the following {“metric”:“adj_rate”}

:returns: col_attributes: A dictionary containing the name and type of all the columns in the dataset. This is needed to get the M code in the outer level function to work.

This function loops through all the dataframe’s columns, checks the column’s type (text, number, date), and generates the appropriate TMDL column definition for that type. Dates will only be recocognized as dates if they are in the format (YYYY-MM-DD) i.e. (1999-12-31). If your date is in another format please change in python before calling the add_csv functions.