<Python, numpy> ランダム選択
numpy
さんに、リストから適当に選択するメソッドがあったのでめも。
choice
ちゅうらしい。
In [1]: import numpy as np In [2]: lst = ['hage', 'hagezo', 'hageshiku', 'hagetaka', 'hageo', 'hagekichi', 'hagesaburo'] In [3]: np.random.choice(lst) Out[3]: 'hagezo' In [4]: np.random.choice(lst) Out[4]: 'hagetaka' In [5]: np.random.choice(lst) Out[5]: 'hageo'