How can i convert an ndarray shape (32 by xxx) into a single column dataframe, while discarding the last ten objects of this array
After running a binary classification NLP model over a dataset with batch size of 32, i have an nparray of predictions of size 32 by 300 and the last batch is of size 24. i am trying to rearrange these values in a dataframe. 

predictions.append(logits.argmax(1))


[array([0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0,
       0, 0, 0, 1, 0, 0, 0, 0, 0, 0]), array([0, 1, 0, 0, 0, 0, 0, 0............


however, when i try to convert it to a dataframe, 


df.labels = pd.DataFrame(predictions)
df.labels.head()



this is what i get 

0    0.0
1    0.0
2    0.0
3    0.0
4    0.0
Name: labels, dtype: float64



i want to have the values as 1 or 0 integers, not floats
the final data batch of 32 has NaN from value 24 to 32, instead of being blank


If your column contains NaN it will always be of float type. The presence of NaN values explains therefore why the column is float.

You must have a dimension problem, your predictions variable is two dimensional, 32 x 10, you should flatten it first and then add your 24 elements, see documentions here : 

predictions = predictions.flatten()

to_append = logits.argmax(1) # this is your array with 24 elements 
predictions = predictions.append(to_append)


What happens here is that whan you append a row of 24 elements to a DataFrame with 32 columns, the last columns from 23 to 32 will exist and will automatically be filled with NaN. See some examples here and here.

Why do you want to transform NaN to blank? If blank means an empty string, you shouldn't do that, as you will mix float and string in your column. 

If you want Integer values. You should make an imputation of the NaN values with a constant Integer value (let us say 888):

df = df.fillna(888)


Then you can transform all to int using the function astype : 

df = df.astype('int16')

