Q:

Comparing 2 lists of lists (String and array)

Having a problem making a third list out of the identical strings from the two lists of String and array:
d = [('O', array([ 0.034     , -0.31900001,  1.18900001], dtype=float32)),
    ('H', array([ 0.29499999,  4.56899977,  1.44500005], dtype=float32)),
    ('O', array([ 0.30500001,  7.00199986,  1.88199997], dtype=float32)),
    ('H', array([  0.215     ,  11.07900047,   1.52199996], dtype=float32)),
    ('O', array([  0.23999999,  13.68999958,   1.99199998], dtype=float32)),
    ...]
v = [('H', array([ 0.64899999,  1.29700005,  3.33400011], dtype=float32)),
    ('O', array([-0.131     ,  3.41700006,  3.31900001], dtype=float32)),
    ('H', array([ 0.764     ,  7.69399977,  3.61800003], dtype=float32)),
    ('O', array([  0.15000001,  10.2130003 ,   3.273     ], dtype=float32)),
    ('H', array([  1.01499999,  14.08399963,   3.7420001 ], dtype=float32)),
    ...]

the result I need should contain all 'H' from both lists and all the coordinates of these H (periodically)
result = [('H', array([ 0.29499999,  4.56899977,  1.44500005], dtype=float32)),
         ('H', array([ 0.64899999,  1.29700005,  3.33400011], dtype=float32)),
         ('H', array([  0.215     ,  11.07900047,   1.52199996], dtype=float32)),
         ('H', array([ 0.764     ,  7.69399977,  3.61800003], dtype=float32)),
         ('H', array([  1.01499999,  14.08399963,   3.7420001 ],   dtype=float32)), 
         ...]

Was trying different options, but getting stuck with unhashable type: 'numpy.ndarray' whenever I try to make it in a loop:
result=list(set(d[0][1:]) & set(v[0][1:]))

Many thanks for ideas, suggestions.

A:

You can combine the lists d and v and select the items, that contain an 'H':
[x for x in d + v if x[0] == 'H']

Edit:
The suggestion above will create a new list in memory, that contains both d and v. To be more memory efficient, you cold use itertools.chain: 
from itertools import chain    
[x for x in chain(d, v) if x[0] == 'H']

