1

I have a list 768 values long and need to make a 32*24 array, I have looked at other answers and questions but can't find any like this.

# Example 36 value long list needing to be a 6*6 array

values = [1,2,3,4,5,6,7,8,9,10....36]

# Missing code I can't figure out

array = [[1,2,3,4,5,6],[7,8,9,10,11,12],[13,14,15,16,17,18],[19,20,21,22,23,24],[25,26,27,28,29,30],[31,32,33,34,35,36]]

Thank you for any help or comments

1 Answer 1

1

You can use numpy to do this:

import numpy as np
values = list(range(1, 37))
array = np.array(values).reshape((6, 6))

The result is

array([[ 1,  2,  3,  4,  5,  6],
       [ 7,  8,  9, 10, 11, 12],
       [13, 14, 15, 16, 17, 18],
       [19, 20, 21, 22, 23, 24],
       [25, 26, 27, 28, 29, 30],
       [31, 32, 33, 34, 35, 36]])
Sign up to request clarification or add additional context in comments.

Comments

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.