snowmobile.core.column

Represents a single Column of a SnowFrame, primarily for the purpose of carrying out/tracking operations performed on a given field in order to standardize or re-format it prior to loading into a table.

Module Contents

Classes

Column

A single column within a SnowFrame.

class snowmobile.core.column.Column(original: str, current: Optional[str] = None, prior: Optional[str] = None, src: Optional[str] = None)

Bases: snowmobile.core.Generic

A single column within a SnowFrame.

original

Original column name.

Type

str

current

Current version of the column name.

Type

str

prior

Prior version of the column name (version n-1).

Type

str

src

Column source (original df or added by snowmobile).

Type

str

original

Original column name.

Type

str

src

Source of column; ‘df’ if from source DataFrame, ‘snowmobile’ otherwise.

Type

str

current

Current column name.

Type

str

prior

Prior (version of) column name.

Type

str

update(self)

Migrate from prior to current context within this context.

lower(self)str

Lower case column.

upper(self)str

Upper case column.

static dedupe(current: str, char: Optional[str] = None)str

Dedupes consecutive characters within a string.

Note

  • Must iterate through matches and perform replacements in the order of the largest to the smallest by number of characters; this is to avoid altering the matches found before replacing them.

Parameters
  • current (str) – String containing characters to dedupe.

  • char (str) – Character to dedupe.

reformat(self, fill_char: Optional[str] = None, dedupe_special: bool = True)str

Reformat column for a load to the database.

Parameters
  • fill_char (str) – Character to replace special characters and whitespace with; defaults to _.

  • dedupe_special (bool) – Dedupe consecutive special characters; defaults to True.