Home > other >  How to network elements according to two related dataframe retreat timetable
How to network elements according to two related dataframe retreat timetable

Time:10-09

I'd like to make a statistical nets yuan back take situation, but each net yuan yuan has a subnet, only on the subnet yuan all backing down clothing, clothing to calculate the net yuan so involves two dataframe,
 import pandas as pd 
Ne=pd. DataFrame ({" NE_Name ": [" A", "A", "A", "D", "D", "B", "B", "B", "C", "C", "C", "C"),
"NE_Unit" : [" A1 ", "A2" and "A3", "D2", "D3", "B1" and "B2", "B3", "C1", "C2", "C3", "C4"]})

Df=pd DataFrame ({" NE_Name ": [" A", "A", "A", "D", "D", "B", "B", "A", "A", "A", "A"],
"NE_Unit" : [" A1 ", "A2" and "A3", "D2", "D3", "B1" and "B3", "A1", "A2" and "A3", "A2"],
"Event_Time" : [" 2017/2/1 5:55:51, "
"2017/2/1 5:55:52,"
"2017/2/1 5:55:54,"
"2017/2/1 6:05:30,"
"2017/2/1 6:05:30,"
"2017/2/1 7:10:30,"
"2017/2/1 7:10:30,"
"2017/2/1 7:24:11,"
"2017/2/1 7:24:21,"
"2017/2/1 7:24:11,"
"2017/2/1 7:55:21],"
"Clear_Time" : [" 2017/2/1 5:58:38, "
"2017/2/1 5:58:48,"
"2017/2/1 5:58:38,"
"2017/2/1 7:02:06,"
"2017/2/1 7:02:06,"
"2017/2/1 7:18:36,"
"2017/2/1 7:18:16,"
"2017/2/1 7:53:37,"
"2017/2/1 7:53:37,"
"2017/2/1 7:53:37,"
"2017/2/1 7:59:55]})"



Ne and df two dataframe
 df 

Clear_Time Event_Time NE_Name NE_Unit
0 2017/2/1 5:58:38 2017/2/1 5:55:51 A A1
1 2017/2/1 5:58:48 2017/2/1 5:55:52 A A2
2 2017/2/1 5:58:38 2017/2/1 5:55:54 A A3
3 2017/2/1 7:02:06 2017/2/1 6:05:30 D D2
4 2017/2/1 7:02:06 2017/2/1 6:05:30 D D3
5 2017/2/1 7:18:36 2017/2/1 7:10:30 B1 B
6 2017/2/1 7:18:16 2017/2/1 7:10:30 B3 B
7 2017/2/1 7:53:37 2017/2/1 7:24:11 A A1
8 2017/2/1 7:53:37 2017/2/1 7:24:21 A A2
9 2017/2/1 7:53:37 2017/2/1 7:24:11 A A3
10 2017/2/1 7:59:55 2017/2/1 7:55:21 A A2


Ne

NE_Name NE_Unit
0 A A1
1 A A2
2 A A3
3 D D2
4 D D3
5 B B1
6 B B2
7 B B3
8 C C1
9 C C2
10 C C3
11 C C4



Finally I want to get the following form:
 Clear_Time Event_Time NE_Name 
2017/2/1 5:58:48 2017/2/1 5:55:54 A
2017/2/1 7:02:06 2017/2/1 6:05:30 D
2017/2/1 7:53:37 2017/2/1 7:24:21 A

Copy the code

Explain:
1. Because in the df network under yuan B2 B didn't suit, so the final result B not counted
2. Take time to back a subnet yuan last a net yuan back take time for the net back take time, recovery time in subnet yuan the earliest a recovery time for the network recovery time
3. There is a net yuan back many times in the df suit case, calculate
Which friend help you see how to solve, first thank you,
  • Related