I am fairly new to python. Presently, I have a pandas series pds
pds.shape
#(1159,)
pds
has an index which is not sequential and at each index there is a (18,100)
array
pds[pds.index[1]].shape
#(18, 100)
How can I convert this to a pandas dataframe and/or a numpy array with dimensions (1159,18,100)
?
pdf = pd.DataFrame(pds)
gives me a pandas with shape
pdf.shape
(1159, 1)
Does this work: numpy.stack([pds[pds.index[i]] for i in range(1159)], axis=0)
?
stack should put all your arrays together along the axis given.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments