COLLATE
Action
¶
Bases: BaseSchemaAction
Collate a list of source fields into an array of corresponding values in a destination field.
Script template
"COLLATE > 'destination_field' < ['source_field', 'source_field', etc.]"
Where the order of collation is important and is used to create an array (list) of values from corresponding sources.
Any missing values will be included as None
.
This can be used as part of a process which will permit multiple corresponding columns (e.g. a date
, description
,
value
sequence) to each be placed in an array, and then pivoted using df.explode
.
Example
"COLLATE > 'laReliefExemptionAmount' < ['Mandatory Relief Amount', 'Discretionary Relief Amount', 'Additional Relief Amount', 'Small Business Rate Relief Amount']"
"CATEGORISE > 'laReliefExemptionType'::'mandatory' < 'Mandatory Relief Code'::['COMMUNITY AMATEUR SPORTS CLUB RELIEFM','MANDATORY 80%']"
"CATEGORISE > 'laReliefExemptionType'::'discretionary' < 'Discretionary Relief Code'::['20%']"
"CATEGORISE > 'laReliefExemptionType'::'retail' < 'Additional Relief Code'::['RETAIL SCHEME']"
"CATEGORISE > 'laReliefExemptionType'::'small_business' < 'Small Business Rate Relief'::['yes']"
pandas
transform:
df = df.explode(["laReliefExemptionType","laReliefExemptionAmount"])