Skip to content

module samples.sample_record_processor

Interact with ZARP sample records.

Global Variables

  • columns_model

class SampleRecordProcessor

ZARP sample record processor class.

Defines methods to append and update sample records.

Attributes:

  • samples: Sequence of Sample objects.

method __init__

__init__()  None

Class constructor method.


method append

append(df: DataFrame, **kwargs: Any)  None

Append dataframe to records.

Duplicate records and extra columns will be dropped.

Args:

  • df: Pandas DataFrame object.
  • **kwargs: Keyword arguments to pass to _sanitize_df().

method append_from_obj

append_from_obj(samples: Sequence[Sample], **kwargs: Any)  None

Append samples to records.

Duplicate records and extra fields will be dropped.

Args:

  • samples: Sequence of Sample objects.
  • **kwargs: Keyword arguments to pass to append().

method update

update(
    df: DataFrame,
    by: Optional[str] = None,
    overwrite: bool = False,
    **kwargs: Any
)  None

Update records with dataframe.

Args:

  • df: Pandas DataFrame object.
  • by: Column to use as index for update. If None (default), compares database records by position.
  • overwrite: Overwrite existing records. If False (default), existing records will not be updated.
  • **kwargs: Keyword arguments to pass to _sanitize_df().

Raises:

  • KeyError: Column indicated by by not found in records or dataframe.
  • ValueError: Records and dataframe have different lengths/rows.

method view

view(
    level: int = 10,
    rows: Optional[int] = None,
    columns: Optional[int] = None,
    width: Optional[int] = None
)  None

Show records.

Args:

  • level: Logging level to use.
  • rows: Number of rows to show.
  • columns: Number of columns to show.
  • width: Maximum column width.