I have a dataframe in which I would like to store \'raw\' numpy.array:
df[\'COL_ARRAY\'] = df.apply(lambda r: np.array(do_something_with_r), axi
Suppose you have a DataFrame ds and it has a column named as 'class'. If ds['class'] contains strings or numbers, and you want to change them with numpy.ndarrays or lists, the following code would help. In the code, class2vector is a numpy.ndarray or list and ds_class is a filter condition.
ds['class'] = ds['class'].map(lambda x: class2vector if (isinstance(x, str) and (x == ds_class)) else x)