-1

I have two dataframes, equipment alarms obtained at two different moments of time, each alarm is a row of the dataframe, I need to compare them and find out if the new alarm exists, I give an example

alarms time 0:

   Sequence    AlarmId  Level                                        Description
0    142527  0x813007C      1  2022-10-20 Loss of signal alarm. (hwPhysicalPo...
1    142526  0x8520003      2  2022-10-20 The interface status changes. (ifNa...
2    142525  0x8520003      2  2022-10-20 The interface status changes. (ifNa...

alarm time 1

   Sequence    AlarmId  Level                                        Description
0    142527  0x813007C      1  2022-10-20 Loss of signal alarm. (hwPhysicalPo...
1    142526  0x8520003      2  2022-10-20 The interface status changes. (ifNa...
2    142525  0x8520003      2  2022-10-20 The interface status changes. (ifNa...
3    142524  0x8520003      2  2022-10-20 The interface status changes. (ifNa...
4    142523  0x81300A8      1  2022-10-20 The status of the physical interfac...

I need obtain:


3    142524  0x8520003      2  2022-10-20 The interface status changes. (ifNa...
4    142523  0x81300A8      1  2022-10-20 The status of the physical interfac...

I think I could use the merge method. Thanks!!

crist_9
  • 33
  • 4
  • Does this answer your question? [Merge two python pandas data frames of different length but keep all rows in output data frame](https://stackoverflow.com/questions/33086881/merge-two-python-pandas-data-frames-of-different-length-but-keep-all-rows-in-out) – Capie Nov 04 '22 at 09:47

1 Answers1

1

You can use the isin function without merge. Check the value in the second df in the first df. Drop what's in both dataframes using ~. :

alarm_time_1 = alarm_time_1[~alarm_time_1['Sequence'].isin(alarms_time_0['Sequence'])]
Bushmaster
  • 4,196
  • 3
  • 8
  • 28