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), axis=1)
but it seems that pandas
tries to 'unpack' the numpy.array.
Is there a workaround? Other than using a wrapper (see edit below)?
I tried reduce=False
with no success.
EDIT
This works, but I have to use the 'dummy' Data
class to wrap around the array, which is unsatisfactory and not very elegant.
class Data:
def __init__(self, v):
self.v = v
meas = pd.read_excel(DATA_FILE)
meas['DATA'] = meas.apply(
lambda r: Data(np.array(pd.read_csv(r['filename'])))),
axis=1
)