Ask Your Question
2

How can I assign a common identifier to all rows that exceed a certain threshold within a provided time frame?

asked 2022-04-09 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-05-11 08:00:00 +0000

plato gravatar image

To assign a common identifier to all rows that exceed a certain threshold within a provided time frame, you can follow these steps:

  1. Sort the dataset by the time column in ascending order.
  2. Create a new column for the identifier and initialize it with a null or blank value.
  3. Set a threshold value for the metric that you want to monitor.
  4. Iterate through each row in the dataset and check if the metric value exceeds the threshold.
  5. If the metric value exceeds the threshold, check if the time difference between the current row and the previous row is within the provided time frame.
  6. If the time difference is within the time frame, assign the same identifier value to both rows.
  7. If the time difference is outside the time frame, assign a new identifier value to the current row.
  8. Repeat steps 5-7 for all rows in the dataset.
  9. Save the dataset with the updated identifier column.

For example, if you want to monitor the number of sales exceeding 100 within a 1-hour time frame, you can follow the above steps and assign a unique identifier to all rows that meet this criteria. This identifier can then be used to filter, group, or analyze the data further.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-04-09 11:00:00 +0000

Seen: 7 times

Last updated: May 11 '21