0

I have the problem of splitting an array from my big data. So i have an array of data, which has the shape of (86594,12).

data=([1,2,3,4,5,6,7,8..,12],[13,14,15,16,17,18...24],...[86583,86584, ...86594])

I want to split it so that i can make a new arrays out from the data. If new array has the shape of (10,12) then I will have that array for into 8659. Please tell me how to do that in python? my expected result will be 8659 arrays with the shape of (10,12) so not in the whole data array of (86594,12)

mstfa23
  • 19
  • 1
  • 6
  • 1
    what is your expected output? – sachin dubey Nov 28 '17 at 05:51
  • Do you want to [flatten the list](https://stackoverflow.com/questions/11264684/flatten-list-of-lists) ? – Abhijeetk431 Nov 28 '17 at 05:51
  • @sachindubey my expected result will be that i have 8659 arrays with the shape of (10,12) so not in the whole data, an array of (86594,12) – mstfa23 Nov 28 '17 at 06:04
  • @Abhijeetk431 i don't, i want to split my array of data, which has the shape of (86594,12) into 8659 arrays which has the shape of (10,12). – mstfa23 Nov 28 '17 at 06:08
  • What do you expect to happen with the last (4, 12) elements after you created your (8659, 10, 12) list? – Mr. T Nov 28 '17 at 10:46
  • Possible duplicate of [How do you split a list into evenly sized chunks?](https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks), [Splitting a list into N parts of approximately equal length](https://stackoverflow.com/questions/2130016/splitting-a-list-into-n-parts-of-approximately-equal-length) and similar – Mr. T Nov 28 '17 at 10:47

1 Answers1

2

Maybe you can use some numpy methods, like np.reshape

 >>> data = np.array([1,2,3,4,5,6,7,8..,12],[13,14,15,16,17,18...24],...[86583,86584, ...86594])
 >>> np.reshape(data, (10,12)) # C-like index ordering
Alan Garrido
  • 484
  • 4
  • 12
  • 1
    `np.arange()` doesn't work with lists. You probably mean `np.asarray()` or `np.array()`. https://stackoverflow.com/questions/14415741/numpy-array-vs-asarray#14415801 But even then `np.reshape()` would just throw an error, because 86594 is not divisible by 10. – Mr. T Nov 28 '17 at 07:19
  • My fault, I mean array, then reshape would work if he add the missing lists – Alan Garrido Nov 28 '17 at 23:08