I have a pandas df that looks like this:
beta 0 matrix([, , ]) 1 matrix([, , ]) 2 matrix([, , ]) : 999 matrix([, , ])
And I want to access the first entry of
df['beta'], idealy either a list or a np array that looks like:
[1, 2, 0, ..., 2]
What I have tried so far:
Convert the series to a list of lists
b_t = list(df['beta_t'].apply(lambda x: x.flatten().tolist())) b_t = [row for row in b_t]
This works, but it takes a while in large datasets.
I also tried:
b_t = list(df['beta_t'].apply(lambda x: np.array(x.flatten())))
but this results in a series of series and I don't know how to continue from here.
Any suggestions on how I should improve my codes? Thanks in advance!