I have a pandas Series which contains 2d (?) numpy ndarrays of the same length with the shape (1 ,208), what would be the easiest way to make it into pandas dataframe with 208 columns?
When i tried to make a numpy array, it turned out to be 3D, though I expected it to be 2D
x = []
for i in train_rdkit_desc:
np.reshape(i, 208)
x.append(i)
x = np.array(x)
x.shape
(908, 1, 208)
CodePudding user response:
I think the easiest way:
you can create a list with the name of your numpy arrays. After that use method concatanation by columns (axis = 1):
df3 = pd.concat([numpy1,numpy2,..., numpyn], axis = 1)
Example:
a = np.array([1, 2, 3, 4, 5, 6])
b = np.array([2, 2, 3, 4, 5, 6])
df= pd.concat([pd.DataFrame(a), pd.DataFrame(b)])