2

I am trying to append a numpy array into an already existing dataframe.

df_train = pd.DataFrame()
sk_train = sklearn_representation_train.toarray()

The shape of both dataframe and sk_train is:

sk_train
-> array([[ 0.,  0.,  0., ...,  0.,  0.,  0.],
       [ 0.,  0.,  0., ...,  0.,  0.,  0.],
       [ 0.,  0.,  0., ...,  0.,  0.,  0.],
       ..., 
       [ 0.,  0.,  0., ...,  0.,  0.,  0.],
       [ 0.,  0.,  0., ...,  0.,  0.,  0.],
       [ 0.,  0.,  0., ...,  0.,  0.,  0.]])

sk_train.shape
-> (95851, 2000)

df_train.shape
-> (95851, 9)

How do convert the sk_train numpy array to dataframe and concatenate it to df_train?

bazinga
  • 2,120
  • 4
  • 21
  • 35

0 Answers0