<div dir="ltr">Hi All,<div><br></div><div>I know how to reshape arrays, my problem is a little more complicated than that.</div><div>I am looking for the most efficient way to do the following and an example will help:</div><div><br></div><div>1) I have a an array of bytes   b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]</div><div>This bytes array represents a width of 2 and a height of 3.</div><div>Each 2 bytes in that bytes array makes an unsigned 16 bit integer.</div><div><br></div><div>2) I want to get the following 2 dimensional array from the bytes array where each item in the two dimensional array is an unsigned 16 bit integer</div><div>something like:</div><div><br></div><div>[  </div><div>      [(1,2)    , (3,4)],</div><div>      [(5,6)    , (7,8)],</div><div>      [(9,10)  , (11,12)]</div><div>]</div><div><br></div><div>in the first row there are 2 elements each one is made of 2 bytes from the bytes array etc...</div><div>meaning that </div><div>(1, 2) =  b[0] + b[1] << 8</div><div>(3, 4) =  b[2] + b[3] << 8</div><div>...</div><div>...</div><div><br></div><div>What is the most efficient way to achieve that with numpy ?</div><div>Thanks</div><div>0L</div><div>  </div><div><br></div><div><br></div><div><br></div><div> </div><div><br></div><div>[1] << 8 ,[2], [3, 4]</div></div>