Python Forum
Correlation of Incidents using time difference - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Correlation of Incidents using time difference (/thread-19412.html)



Correlation of Incidents using time difference - Rajhesh - Jun-27-2019

Hi All,

I'm a newbee in Python. Mostly I need to handle files. Lets say, I have a data dump which has records of Incidents for many nodes. A single node can have multiple issues. Now I need to correlate these incidents in order, so that I can have a clear picture over parent Issue and Child issues. For this, I need to filter those incidents group by nodes based on Incident-Occurrence time criteria and the time difference between the first incident and the successor incidents should be less than 15 mins for the same node.

I'm willing to do this through pandas, groupby and conditional statements. If possible, I need a new column to get generated as Parent-child, where I can able to find the respective parent-child issues for the same node

Below is the sample input data:

Node Incident Start time Clear time Incident No Status
714851 INCORRECT OPERATING STATE 16-06-2019 0:42:33 16-06-2019 8:34:19 IM0021 Closed
714851 WDU HAS NO REDUNDANCY 16-06-2019 0:31:29 16-06-2019 8:31:29 IM0013 Closed
720107 INCORRECT WORKING STATE 16-06-2019 12:32:45 IM0046 Open
720107 UNIT TYPE HAS NO REDUNDANCY 16-06-2019 12:38:53 IM0057 Open
720107 WDU hanged 16-06-2019 12:36:53 IM0059 Open
157681 CS U-PLANE CONNECTION FAIL 16-06-2019 14:38:53 17-06-2019 16:38:53 IM0024 Closed
157681 RF unit failure 16-06-2019 18:38:53 IM0064 Open

Output needed is :

Node Incident Start time Clear time Incident No Status Parent-child
714851 INCORRECT OPERATING STATE 16-06-2019 0:42:33 16-06-2019 8:34:19 IM0021 Closed Child1
714851 WDU HAS NO REDUNDANCY 16-06-2019 0:31:29 16-06-2019 8:31:29 IM0013 Closed Parent1
720107 INCORRECT WORKING STATE 16-06-2019 12:32:45 IM0046 Open Parent2
720107 UNIT TYPE HAS NO REDUNDANCY 16-06-2019 12:38:53 IM0059 Open Child2
720107 WDU hanged 16-06-2019 12:36:53 IM0059 Open Child2

Any lights on this.? Thanks in advance.


RE: Correlation of Incidents using time difference - Larz60+ - Jun-27-2019

Is this an assignment?
Please show what you have attempted so far.
Thank you