Вы можете использовать set
операции.
import numpy as np
a=np.array(['Barnet', 'Camden', 'Wandsworth', 'Hounslow', 'Southwark',
'Westminster', 'Kensington & Chelsea', 'Tower Hamlets',
'Islington', 'Kingston', 'Barking & Dagenham', 'Waltham Forest',
'Haringey', 'Lambeth', 'Enfield', 'Greenwich', 'Redbridge',
'Newham', 'City of London', 'Hackney', 'Richmond', 'Ealing',
'Hammersmith & Fulham', 'Lewisham', 'Sutton', 'Havering', 'Bexley',
'Bromley'])
b=np.array(['Kingston upon Thames', 'Croydon', 'Bromley', 'Hounslow', 'Ealing',
'Havering', 'Hillingdon', 'Harrow', 'Brent', 'Barnet', 'Lambeth',
'Southwark', 'Lewisham', 'Greenwich', 'Bexley', 'Enfield',
'Waltham Forest', 'Redbridge', 'Sutton', 'Richmond upon Thames',
'Merton', 'Wandsworth', 'Hammersmith and Fulham',
'Kensington and Chelsea', 'Westminster', 'Camden', 'Tower Hamlets',
'Islington', 'Hackney', 'Haringey', 'Newham',
'Barking and Dagenham', 'City of London'])
print(set(a)-set(b)) #(set A – set B) will be the elements present in set A but not in B
print(set(b)-set(a)) #(set B – set A) will be the elements present in set B but not in set A
print(set(a)-set(b)|set(b)-set(a))
{'Barking & Dagenham',
'Hammersmith & Fulham',
'Kensington & Chelsea',
'Kingston',
'Richmond'} #set(a)-set(b)
{'Barking and Dagenham',
'Brent',
'Croydon',
'Hammersmith and Fulham',
'Harrow',
'Hillingdon',
'Kensington and Chelsea',
'Kingston upon Thames',
'Merton',
'Richmond upon Thames'} #set(b)-set(a)
{'Barking & Dagenham',
'Barking and Dagenham',
'Brent',
'Croydon',
'Hammersmith & Fulham',
'Hammersmith and Fulham',
'Harrow',
'Hillingdon',
'Kensington & Chelsea',
'Kensington and Chelsea',
'Kingston',
'Kingston upon Thames',
'Merton',
'Richmond',
'Richmond upon Thames'}