Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Operator: relative_distance #423

Open
kajen3 opened this issue Apr 16, 2024 · 0 comments
Open

New Operator: relative_distance #423

kajen3 opened this issue Apr 16, 2024 · 0 comments

Comments

@kajen3
Copy link

kajen3 commented Apr 16, 2024

The operator should return the relative distance of the timestamps to a given input timestamp. This is especially useful to compute the distance to special days like public holidays. Example:

# Example 1
a = tp.event_set(timestamps=[1, 2, 4, 5, 7, 9])
a.relative_distance(6)
>>>indexes: []
features: [('relative_distance', int64)]
events:
     (6 events):
        timestamps: [1. 2. 4. 5. 7. 9.]
        'relative_distance': [-4 -3 -2 -1  1  2]

#Example 2
b = tp.event_set(timestamps=[1, 2, 4, 5, 6, 7, 9])
b.relative_distance(6)
>>>indexes: []
features: [('relative_distance, int64)]
events:
     (7 events):
        timestamps: [1. 2. 4. 5. 6. 7. 9.]
        'relative_distance': [-4 -3 -2 -1  0  1  2]
@kajen3 kajen3 changed the title Request for a new `relative_distance' operator. New Operator: `relative_distance' Apr 16, 2024
@kajen3 kajen3 changed the title New Operator: `relative_distance' New Operator: relative_distance Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant