Q:

Creating Dictionaries from arrays in Python

I have 3 numpy arrays :
a = numpy.array([['x','y']])
b = numpy.array([['x1','y1']])
c = numpy.array([['x2','y2']])

I want to create a dictionary as:
d={'x': ['x1','x2'], 'y':['y1','y2']}

How do I create such a dictionary? 

A:

zip the arrays inside a dictionary comprehension:
d = {x: list(*i) for x, i in zip(*a, (b, c))}

or, alternatively:
d = {x: [y, z] for x, (y, z) in zip(*a, (*b, *c))}

or, if you like deep unpacking scenarios:
d = {x: [y, z] for x, ((y, z),) in zip(*a, (b, c))}

there's quite a number of packing/unpacking combinations to choose from.  All these of course produce the same output with the dictionary d now being:
{'x': ['x1', 'y1'], 'y': ['x2', 'y2']}

A:

If you actually want d={'x':['x1','x2'],'y':['y1','y2']} you can go:
d = {i: [j, x] for i,j,x in zip(a,b,c)}

