Check if the Field is a Number

Last updated on Jun 30, 2023
Definition: isNumber(fieldname: str) → bool
Description: Checks if a specific field is of type, number. The return value can be further used to transform the data. For example, deleting a non-numeric field.
Parameters: fieldname: The name of the field whose value is to be checked.
Returns: True, if the specified field’s value is of type, number.
False, for null and non-numeric values.

The following script checks if the specified property is a number:

from io.hevo.api import Event

def transform(event):
    <existing_properties> = event.getProperties()

    <boolean_value_type> = event.isNumber('<property_name>')

    return event

Sample Transformation

The following script checks if the last4 property is a number. The isNumber property displays the return value of the method:

from io.hevo.api import Event

def transform(event):
    properties = event.getProperties()

    # Set a property to the return value of the method
    properties['isNumber'] = event.isNumber('last4')

    return event

Sample Output

The Transformation sets the isNumber property to true, as last4 is a number.

Is a Number



Revision History

Refer to the following table for the list of key updates made to this page:

Date Release Description of Change
Feb-14-2023 NA New document.

Tell us what went wrong