clean_results.remove_entries_based_on_indices

clean_results.remove_entries_based_on_indices(data, nan_indices, exceptions=[])[source]

Remove entries at specified indices from nested data structures.

This helper function recursively traverses dictionaries and lists, removing entries at specified indices while preserving structure and handling exceptions.

Parameters:
  • data (dict or list) – The data structure to clean. Can be nested to any depth.

  • nan_indices (list of int) – Indices of entries to remove

  • exceptions (list of str, optional) – Keys in dictionaries that should not have entries removed, typically metadata fields

Returns:

If input is a list, returns filtered list If input is a dict, modifies in place and returns None

Return type:

list or None

Notes

The function handles three cases: 1. Dictionaries: Recursively process each value 2. Lists: Filter out specified indices 3. Exception keys: Skip processing entirely