May
02

compare two lists

It is very easy to compare two lists in python, but it seems not so many people know it.

Just use the `==` symbol in numpy, it will return a numpy array with boolean value, True means the position are idential.

import numpy as np

aa = [“a”,”b”,”a”]
bb = [“b”,”b”,”a”]

np.array(aa)==np.array(bb)

>>array([False, True, True], dtype=bool)

see my example code in stackoverflow:

http://stackoverflow.com/a/36983379/3279996

Written by connygy. Posted in Uncategorized

Trackback from your site.

Leave a comment