Johan Nilssons Lifestream

How to get new time data?

I have two data table using pandas and column labels: .

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", "A3", "D2", "D3", "B1", "B2", "B3", "C1", "C2", "C3", "C4"]})

df = pd.DataFrame({"NE_Name": ["A", "A", "A", "D", "D", "B", "B", "C", "C", "C", "C"],
                   "NE_Unit": ["A1", "A2", "A3", "D2", "D3", "B1", "B3", "C1", "C2", "C3", "C4"],
                   "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:24:11"],
                   "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:53:37"]})

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    B   B1
6   2017/2/1 7:18:16    2017/2/1 7:10:30    B   B3
7   2017/2/1 7:53:37    2017/2/1 7:24:11    C   C1
8   2017/2/1 7:53:37    2017/2/1 7:24:21    C   C2
9   2017/2/1 7:53:37    2017/2/1 7:24:11    C   C3
10  2017/2/1 7:53:37    2017/2/1 7:24:11    C   C4

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

I want to get this:

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    C

I tested for a long time, did not solve.

I want to get back to the NE Event_Time and Clear_Time.

as other people (see here and here ) ran into the problem that I could not edit a question, because the error "It look like your post is mostly code; add some more details. " appeared.

via Stack Overflow

blog comments powered by Disqus
Get the source for phplifestream at Github