libb.backfill_iterdict

backfill_iterdict(iterdict)

Back-fill a sorted iterdict with the latest values.

Parameters:

iterdict – List of dicts with possibly None values.

Returns:

List of dicts with None values replaced by most recent non-None values per key.

Examples

>>> backfill_iterdict([{'a': 1, 'b': None}, {'a': 4, 'b': 2}, {'a': None, 'b': None}])
[{'a': 1, 'b': 2}, {'a': 4, 'b': 2}, {'a': 4, 'b': 2}]