python - Convert list of NDarrays to dataframe -
i'm trying convert list nd arrays dataframe in order isomap on it. doesn't convert. how convert in such can isomap on it?
#creation , filling of list samples* samples = list() in range(72): img =misc.imread('datasets/aloi/32/32_r'+str(i*5)+'.png' ) samples.append(img) ... df = pd.dataframe(samples) #this doesn't work gives #valueerror: must pass 2-d input* ... iso = manifold.isomap(n_neighbors=4, n_components=3) iso.fit(df) #the end goal of dataframe
that obvious, isn't it? images 2d data, rows , columns. stacking them in list causes gain third dimension. dataframes nature 2d. hence error.
you have 2 possible fixes:
create panel.
wp = pd.panel.from_dict(zip(samples, [str(i*5) in range(72)]))
stack arrays 1 on top of other, or side side:
# on top of another: df = pd.concat([pd.dataframe(sample) sample in samples], axis=0, keys=[str(i*5) in range(72)]) # side side: df = pd.concat([pd.dataframe(sample) sample in samples], axis=1, keys=[str(i*5) in range(72)])
Comments
Post a Comment