pymovements.Dataset.drop_nulls#

Dataset.drop_nulls(subset: list[str] | None = None, how: Literal['all', 'any'] = 'any', samples: bool = True, events: bool = True) → Dataset[source]#

Drop samples and events with null values.

Parameters:
  • subset (list[str] | None) – List of column names to check for null values. If None, each frame is checked on its own columns: sample frames on all sample columns, event frames on all event columns. If a list is given, all named columns must exist in every targeted frame. (default: None)

  • how (Literal['all', 'any']) – If ‘any’, drop rows where any of the specified columns are null. If ‘all’, drop rows where all of the specified columns are null. A nested list column like pixel or position counts as null if any of its components is null under ‘any’, and only if all of its components are null under ‘all’. (default: ‘any’)

  • samples (bool) – If True, drop samples with null values. (default: True)

  • events (bool) – If True, drop events with null values. (default: True)

Returns:

Returns self, useful for method cascading.

Return type:

Dataset

Raises:

ValueError – If how is neither ‘any’ nor ‘all’, or if subset contains columns that do not exist in a targeted frame.

Examples

Initialize your Dataset object and load the data first:

>>> import pymovements as pm
>>>
>>> dataset = pm.Dataset("ToyDataset", path='data/ToyDataset')
>>> dataset.load()

Drop all samples and events with null values:

>>> dataset.drop_nulls()

Drop only samples where any pixel component is null:

>>> dataset.drop_nulls(subset=['pixel'], events=False)