Time to Event

This transform calculates the duration between two events in a dataset using Pandas and creates a new column called time to event. This column has the duration between events, which is expressed in seconds, hours, minutes, days, weeks, months or years. Time to event analyzes how long it takes for a particular event to occur after another event has happened.

tags: [“Data Preparation”]

Parameters

The table gives a brief description about each parameter in Time to Event transform.

Name:

By default, the transform name is populated. You can also add a custom name for the transform.

Timeseries dataset:

The file name of the input dataset. You can select the dataset that was uploaded from the drop-down list. (Required: True, Multiple: False)

Event dataset:

The file name of the event dataset. This contains the date and time at which an event happened. (Required: True, Multiple: False)

Timeseries key:

The column which can be the joining key in the timeseries dataset.

Event key:

The column which can be the joining key in the Event dataset.

Timeseries Timestamp:

The time stamp column in the timeseries dataset to be compared with the event timestamp. You must provide the timestamp column name as in the dataset.

Event Timestamp:

The time stamp column in the event dataset. You must provide the timestamp column name as in the event dataset.

Unit of time:

The unit of time used to calculate the time difference and predict the time to event. Possible values:

  • seconds

  • minutes

  • hours

  • days

  • weeks

  • months

  • years

Output Dataset:

The file name with which the output dataset is created. This contains a new column called time to event displaying the duration between the events.

The sample input for this transform looks as shown in the screenshot:

../../../_images/timetoevent_input.png

The output or result after adding the Time to Event transform looks as below:

../../../_images/timetoevent_output.png

How to use it in Notebook

The following is the code snippet you must use in the Jupyter Notebook editor to run the Time to Event transform:

template=TemplateV2.get_template_by('Take Value')

recipe_Take_Value= project.addRecipe([car_data, employee_data, temperature_data, only_numeric], name='Take Value')

transform=Transform()
transform.templateId = template.id
transform.name='Take Value'
transform.variables = {
'input_dataset':'car',
'output_dataset':'car_taken',
'value_1':"[1]",
'value_2':0}
recipe_Take_Value.add_transform(transform)
recipe_Take_Value.run()

Requirements

pandas