Share

Modify the Properties for an Event

Definition: setProperties(props: dict) → None
Description: Modifies the specified properties for the Event.
Parameters: props: The new properties to be set.
Returns: No return value, which is indicated by None.

The following script modifies the properties of an Event:

from io.hevo.api import Event

def transform(event):

    <new_properties> = {}
    <new_properties>['<property_1>'] = <new_value>

    event.setProperties(<new_properties>)

    return event

Sample Transformation

The following script demonstrates the use of this method. It:

  1. Retrieves the existing set of properties.

  2. Creates a new dictionary of properties called new_properties, and in this dictionary:

    • Adds the School_ID property.

    • Modifies the value in the Marks property.

    • Adds the Student Name property.

  3. Uses the setProperties() method to set the properties of the Event to new_properties.

As a result, the remaining properties of the Event, including any Hevo-generated metadata properties, are deleted.

from io.hevo.api import Event

def transform(event):
    # Get properties from the event
    properties = event.getProperties()

    new_properties = {}
    new_properties['Student Name'] = properties['Student Name']
    new_properties['Marks'] = properties['Marks'] * 0.9
    new_properties['School_ID'] = '1'

    # Set a dictionary as the properties
    event.setProperties(new_properties)

    return event

Sample Output

The following image displays the sample Event and the transformed Event with just the School_ID, Marks, and Student Name properties.

Modify Properties


Last updated on Jun 30, 2023

Tell us what went wrong

Skip to the section