Skip to content

digiplan.map.utils#

Module for smaller helper functions.

get_translated_json_from_file(json_filename, request=None) #

Render JSON using translations.

Parameters#

json_filename: str Path to JSON file request: HttpRequest Used to create RequestContext and set language from request

Returns#

dict translated JSON file as dictionary

interpolate_year_from_dataframe(df, year) #

Return series from dataframe for given year.

If the given year is not present in dataframe columns, interpolate the data given available years.

interpolate_year_from_dict(data, year) #

Extract or interpolate value from dict for given year.

merge_dicts(dict1, dict2) #

Recursively merge two dictionaries.

Parameters#

dict1: dict Containing the first chart structure. Objects will be first. dict2: dict Containing the second chart structure. Objects will be last and if they have the same name as ones from dict1 they overwrite the ones in first.

Returns#

dict First chart modified and appended by second chart.

read_file(filename) #

Read file.