1

I have a data frame like this. [from csv file]

       l1  p1 p2 p3 ... p10
    0   ↑  ←---- rows ----→
    1   |  ←---- rows ----→
    2   c  ←---- rows ----→
    3   o  ←---- rows ----→
    .   l  ←---- rows ----→
    .   |  ←---- rows ----→
    9   ↓  ←---- rows ----→

I want to convert l1 column into numpy array like this
[ ←, -, c, o, l, -, →] size : 10
and all the remaining columns into another numpy array like this\

[[ ← - r o w s - →],
 [ ← - r o w s - →],
 [ ← - r o w s - →]]    size: (10, 10)

Also


columns in the data frame are images so how can I further divide my data frame like this

           l1   p1 p2 .... p784
    0       ↑  ←---- rows ----→
    1       |  ←---- rows ----→
    2       c  ←---- rows ----→
    3       o  ←---- rows ----→
    .       l  ←---- rows ----→
    .       |  ←---- rows ----→
    27455   ↓  ←---- rows ----→

After getting the rows array on this data frame I will have numpy array of size(27455, 784) How to further split this array into size(27455, 28, 28)

how to do this !!
any other way will also be appreciated !!

1 Answer 1

2

Try

col=df.l1.to_numpy()

ary=df.drop('l1',axis=1).to_numpy()
Sign up to request clarification or add additional context in comments.

3 Comments

I was about to accept your answer than system said to wait for 7 min !! Than I was editing the question and here I am ...
@Manan df.drop('l1',axis=1).to_numpy().reshape(len(df),-1,28).shape for you update question
(o_ _)ノ彡☆ Nice !!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.