eelbrain.Factor.floodfill

Factor.floodfill(regions, empty='')

Fill in empty regions in a Factor from the nearest non-empty value

Parameters:
  • regions (array_like | str) – How to define regions to fill. Can be an object with same length as the factor that indicates regions to fill (see example). Can also be "previous", in which case the last value before the empty cell is used.

  • empty (str) – Value that is to be treated as empty (default is ‘’).

Examples

>>> f = Factor(['', '', 'a', '', '', '', 'b', ''])
>>> f.floodfill([1, 1, 1, 1, 2, 2, 2, 2])
Factor(['a', 'a', 'a', 'a', 'b', 'b', 'b', 'b'])
>>> f.floodfill([1, 1, 1, 2, 2, 2, 2, 2])
Factor(['a', 'a', 'a', 'b', 'b', 'b', 'b', 'b'])
>>> f.floodfill([1, 1, 1, 1, 1, 1, 1, 1])
Factor(['a', 'a', 'a', 'a', 'a', 'a', 'b', 'b'])