def _adjust_date(data: DataFrame, aux: DataFrame) -> DataFrame: """ Adjust the date of the data based on the report offset """ # Save the current columns to filter others out at the end data_columns = data.columns # Filter auxiliary dataset to only get the relevant keys data = data.merge(aux, suffixes=("", "aux_"), how="left") # Perform date adjustment for all records so date is consistent across datasets data.aggregate_report_offset = data.aggregate_report_offset.apply( safe_int_cast) data["date"] = data.apply(lambda x: date_offset( x["date"], get_or_default(x, "aggregate_report_offset", 0)), axis=1) return data[data_columns]
def default_adapter(value: str): if isna(value): return mapping["unknown"] value = re.sub(r"[\s\-]", "_", unidecode(str(value).lower())) return get_or_default(mapping, value, mapping["unknown"])